mirror of
https://github.com/boostorg/detail.git
synced 2025-07-30 04:17:14 +02:00
Merged revisions 44564,44567-44570,44595,44597,44602-44612,44614-44615,44620-44640,44645-44646,44650-44657,44659-44660,44662-44663,44665-44676 via svnmerge from
https://svn.boost.org/svn/boost/trunk ................ r44564 | hkaiser | 2008-04-18 17:23:19 -0700 (Fri, 18 Apr 2008) | 1 line Spirit.Qi: Fixed a big endian issue in tests/qi/binary.cpp ................ r44567 | hkaiser | 2008-04-18 17:52:54 -0700 (Fri, 18 Apr 2008) | 1 line Wave: Added a missing header file. ................ r44568 | hkaiser | 2008-04-18 18:11:17 -0700 (Fri, 18 Apr 2008) | 1 line Spirit: removed multi_pass tests from regression runs, these are not completed yet. ................ r44569 | djowel | 2008-04-18 19:13:57 -0700 (Fri, 18 Apr 2008) | 1 line no-case for chsets ................ r44570 | djowel | 2008-04-18 19:14:11 -0700 (Fri, 18 Apr 2008) | 1 line no-case for chsets ................ r44595 | johnmaddock | 2008-04-19 09:28:00 -0700 (Sat, 19 Apr 2008) | 1 line Changed #includes to avoid circular dependencies between shared_ptr and TR1. ................ r44597 | hkaiser | 2008-04-19 09:41:29 -0700 (Sat, 19 Apr 2008) | 1 line Spirit.Karma: disabled real_numerics tests for real_concept for now. ................ r44602 | hkaiser | 2008-04-19 12:59:59 -0700 (Sat, 19 Apr 2008) | 1 line Wave: fixing compilation using Intel compilers ................ r44603 | hkaiser | 2008-04-19 13:03:21 -0700 (Sat, 19 Apr 2008) | 1 line Wave: Added workaround for VC7.1 ................ r44604 | hkaiser | 2008-04-19 13:09:11 -0700 (Sat, 19 Apr 2008) | 1 line Wave: Applied a fix for HP Tru64 compiler ................ r44605 | hkaiser | 2008-04-19 13:22:39 -0700 (Sat, 19 Apr 2008) | 1 line Spirit: renamed end_type to eoi_type (missed that while original renaming) ................ r44606 | bemandawes | 2008-04-19 14:13:59 -0700 (Sat, 19 Apr 2008) | 1 line replace_extension -> change_extension name fix [Lothar May] ................ r44607 | hkaiser | 2008-04-19 14:15:37 -0700 (Sat, 19 Apr 2008) | 1 line Wave: attempt to fix test runs ................ r44608 | hkaiser | 2008-04-19 18:42:27 -0700 (Sat, 19 Apr 2008) | 1 line Spirit.Lex: First version of wrapped semantic actions. ................ r44609 | djowel | 2008-04-20 01:00:41 -0700 (Sun, 20 Apr 2008) | 1 line add wchar test ................ r44610 | djowel | 2008-04-20 01:27:25 -0700 (Sun, 20 Apr 2008) | 1 line various fixes ................ r44611 | djowel | 2008-04-20 01:27:41 -0700 (Sun, 20 Apr 2008) | 1 line more tests ................ r44612 | johnmaddock | 2008-04-20 03:58:20 -0700 (Sun, 20 Apr 2008) | 4 lines Moved real_concept and std_real_concept overloads of the rounding and truncation functions into the same namespace as the classes so that they can be found via ADL. Updated the tests to cope with the change. Updated library configuration to cope with the change. Made sure that the rounding and truncation functions are all correctly forward declared. ................ r44614 | danieljames | 2008-04-20 05:10:56 -0700 (Sun, 20 Apr 2008) | 15 lines Merge in fix for the swap tests, and rename allocator. Merged revisions 44512-44515,44517-44536 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ................ r44512 | danieljames | 2008-04-17 20:03:00 +0100 (Thu, 17 Apr 2008) | 11 lines Rename allocator.hpp. ................ r44536 | danieljames | 2008-04-18 11:27:50 +0100 (Fri, 18 Apr 2008) | 1 line Check that hash_table_impl::swap isn't swapping with itself - which is causing the buffered functions to be set with the same value twice, resulting in an assertion. ................ ................ r44615 | danieljames | 2008-04-20 05:11:22 -0700 (Sun, 20 Apr 2008) | 1 line Remove some tabs. ................ r44620 | johnmaddock | 2008-04-20 05:53:37 -0700 (Sun, 20 Apr 2008) | 1 line Added docs for new warning_disable.hpp header. ................ r44621 | johnmaddock | 2008-04-20 05:54:21 -0700 (Sun, 20 Apr 2008) | 1 line Added new warning_disable.hpp header. ................ r44622 | hkaiser | 2008-04-20 06:00:21 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Karma: re-enabled real_numerics tests related to math::real_concept. ................ r44623 | hkaiser | 2008-04-20 06:13:42 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Changed wrap_action::phoenix_action to be a embedded function object. Same errors still... ................ r44624 | hkaiser | 2008-04-20 06:24:11 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Worked around a problem related to HP-UX_ia64_aCC. ................ r44625 | hkaiser | 2008-04-20 06:25:47 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Reverted wrap_action code to use Boost.Bind for now, just to avoid regression errors. ................ r44626 | hkaiser | 2008-04-20 06:30:15 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Added a workaround for missing WCHAR_MAX constant. ................ r44627 | hkaiser | 2008-04-20 06:33:53 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Added another workaround for wchar.h ................ r44628 | hkaiser | 2008-04-20 06:37:42 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Yet another wchar_t fix. ................ r44629 | hkaiser | 2008-04-20 06:45:06 -0700 (Sun, 20 Apr 2008) | 1 line Spirit: Added a missing header #include. ................ r44630 | hkaiser | 2008-04-20 06:46:10 -0700 (Sun, 20 Apr 2008) | 1 line Spirit: Added a missing header #include. ................ r44631 | hkaiser | 2008-04-20 06:51:15 -0700 (Sun, 20 Apr 2008) | 1 line Added some parenthesis to disambiguate expressions. ................ r44632 | hkaiser | 2008-04-20 06:57:47 -0700 (Sun, 20 Apr 2008) | 1 line Spirit: Added a missing header #include. ................ r44633 | hkaiser | 2008-04-20 07:01:18 -0700 (Sun, 20 Apr 2008) | 1 line Spirit: Added a missing header #include. ................ r44634 | hkaiser | 2008-04-20 07:01:34 -0700 (Sun, 20 Apr 2008) | 1 line Spirit: Added a missing header #include. ................ r44635 | hkaiser | 2008-04-20 07:04:08 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Fixed a gcc4.3.0 compilation error. ................ r44636 | pdimov | 2008-04-20 07:59:12 -0700 (Sun, 20 Apr 2008) | 1 line Atomic access added. ................ r44637 | hkaiser | 2008-04-20 08:27:30 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Qi: Fixed eol parser ................ r44638 | pdimov | 2008-04-20 08:37:08 -0700 (Sun, 20 Apr 2008) | 1 line Factored out boost/detail/lightweight_thread.hpp. ................ r44639 | hkaiser | 2008-04-20 10:00:35 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Qi: Fixed lit parser ................ r44640 | pdimov | 2008-04-20 10:00:58 -0700 (Sun, 20 Apr 2008) | 1 line sp_atomic_mt_test.cpp added. ................ r44645 | danieljames | 2008-04-20 11:30:21 -0700 (Sun, 20 Apr 2008) | 1 line Initialise svnmerge for the doc branch. ................ r44646 | danieljames | 2008-04-20 11:35:31 -0700 (Sun, 20 Apr 2008) | 1 line Fix svnmerge for the doc branch. ................ r44650 | danieljames | 2008-04-20 14:08:57 -0700 (Sun, 20 Apr 2008) | 1 line Update an include. ................ r44651 | djowel | 2008-04-20 14:11:44 -0700 (Sun, 20 Apr 2008) | 1 line problem fixed with lambda[f] ................ r44652 | hkaiser | 2008-04-20 14:27:28 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Fixed VC7.1 compilation issue ................ r44653 | hkaiser | 2008-04-20 14:28:20 -0700 (Sun, 20 Apr 2008) | 1 line Wave: Updated iterator for change in multi_pass ................ r44654 | hkaiser | 2008-04-20 14:29:01 -0700 (Sun, 20 Apr 2008) | 1 line Wave: Updated iterator for change in multi_pass ................ r44655 | hkaiser | 2008-04-20 14:39:36 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Fixed wrap_action ................ r44656 | hkaiser | 2008-04-20 14:44:25 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Cleaning up ... ................ r44657 | hkaiser | 2008-04-20 15:37:35 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: Updated examples. ................ r44659 | hkaiser | 2008-04-20 17:20:39 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Karma: Added actions test ................ r44660 | hkaiser | 2008-04-20 17:29:36 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex. Updated Lexer quickstart docs with new action prototypes ................ r44662 | chris_kohlhoff | 2008-04-20 18:23:42 -0700 (Sun, 20 Apr 2008) | 3 lines Add ability to disable the uses of the typeid operator by defining BOOST_NO_TYPEID or BOOST_ASIO_NO_TYPEID. ................ r44663 | chris_kohlhoff | 2008-04-20 18:27:48 -0700 (Sun, 20 Apr 2008) | 3 lines Ensure that timer dispatching responsibility is correctly relinquished when processing leftover interrupts from a previous run invocation. ................ r44665 | chris_kohlhoff | 2008-04-20 18:36:28 -0700 (Sun, 20 Apr 2008) | 3 lines Enhance example to make it clear that invocation hooking can be used with asynchronous operations. ................ r44666 | chris_kohlhoff | 2008-04-20 18:39:06 -0700 (Sun, 20 Apr 2008) | 3 lines Improve efficiency of basic_streambuf::consume() by using a single call to gbump() rather than calling sbumpc() in a loop. ................ r44667 | chris_kohlhoff | 2008-04-20 18:41:29 -0700 (Sun, 20 Apr 2008) | 2 lines Update version number to match release. ................ r44668 | chris_kohlhoff | 2008-04-20 18:42:10 -0700 (Sun, 20 Apr 2008) | 2 lines Fix infinite recursion in the ssl::stream's shutdown() implementation. ................ r44669 | hkaiser | 2008-04-20 19:01:31 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Qi: Added ~ for eoi and eol, added corresponding tests ................ r44670 | chris_kohlhoff | 2008-04-20 19:01:34 -0700 (Sun, 20 Apr 2008) | 2 lines Improve documentation for the protected functions and data in basic_io_object<>. ................ r44671 | hkaiser | 2008-04-20 19:02:37 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Qi: Added new test to test Jamfile ................ r44672 | hkaiser | 2008-04-20 19:04:06 -0700 (Sun, 20 Apr 2008) | 1 line Spirit.Lex: pending commits, fixed static lexer. ................ r44673 | chris_kohlhoff | 2008-04-20 21:02:37 -0700 (Sun, 20 Apr 2008) | 4 lines Add a special null_buffers type that allows read and write operations to be used to indicate the socket's readiness to read or write without blocking. ................ r44674 | chris_kohlhoff | 2008-04-20 21:43:05 -0700 (Sun, 20 Apr 2008) | 2 lines Add support for UNIX domain sockets. ................ r44675 | chris_kohlhoff | 2008-04-20 22:16:15 -0700 (Sun, 20 Apr 2008) | 2 lines Add new wrapper classes for stream-oriented file descriptors on POSIX platforms. ................ r44676 | chris_kohlhoff | 2008-04-20 22:32:34 -0700 (Sun, 20 Apr 2008) | 2 lines Add new wrapper classes for stream-oriented handles on Windows. ................ [SVN r44680]
This commit is contained in:
135
include/boost/detail/lightweight_thread.hpp
Normal file
135
include/boost/detail/lightweight_thread.hpp
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
#ifndef BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
|
||||||
|
#define BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
|
||||||
|
|
||||||
|
// MS compatible compilers support #pragma once
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||||
|
# pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// boost/detail/lightweight_thread.hpp
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||||
|
// Copyright (c) 2008 Peter Dimov
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <memory>
|
||||||
|
#include <cerrno>
|
||||||
|
|
||||||
|
// pthread_create, pthread_join
|
||||||
|
|
||||||
|
#if defined( BOOST_HAS_PTHREADS )
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <process.h>
|
||||||
|
|
||||||
|
typedef HANDLE pthread_t;
|
||||||
|
|
||||||
|
int pthread_create( pthread_t * thread, void const *, unsigned (__stdcall * start_routine) (void*), void* arg )
|
||||||
|
{
|
||||||
|
HANDLE h = (HANDLE)_beginthreadex( 0, 0, start_routine, arg, 0, 0 );
|
||||||
|
|
||||||
|
if( h != 0 )
|
||||||
|
{
|
||||||
|
*thread = h;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return EAGAIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int pthread_join( pthread_t thread, void ** /*value_ptr*/ )
|
||||||
|
{
|
||||||
|
::WaitForSingleObject( thread, INFINITE );
|
||||||
|
::CloseHandle( thread );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// template<class F> int lw_thread_create( pthread_t & pt, F f );
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
class lw_abstract_thread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual ~lw_abstract_thread() {}
|
||||||
|
virtual void run() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined( BOOST_HAS_PTHREADS )
|
||||||
|
|
||||||
|
extern "C" void * lw_thread_routine( void * pv )
|
||||||
|
{
|
||||||
|
std::auto_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
|
||||||
|
|
||||||
|
pt->run();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
unsigned __stdcall lw_thread_routine( void * pv )
|
||||||
|
{
|
||||||
|
std::auto_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
|
||||||
|
|
||||||
|
pt->run();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<class F> class lw_thread_impl: public lw_abstract_thread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
explicit lw_thread_impl( F f ): f_( f )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
f_();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
F f_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class F> int lw_thread_create( pthread_t & pt, F f )
|
||||||
|
{
|
||||||
|
std::auto_ptr<lw_abstract_thread> p( new lw_thread_impl<F>( f ) );
|
||||||
|
|
||||||
|
int r = pthread_create( &pt, 0, lw_thread_routine, p.get() );
|
||||||
|
|
||||||
|
if( r == 0 )
|
||||||
|
{
|
||||||
|
p.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
|
Reference in New Issue
Block a user