1 #ifndef BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
2 #define BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
9 // boost/detail/lightweight_mutex.hpp - lightweight mutex
11 // Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
13 // Permission to copy, use, modify, sell and distribute this software
14 // is granted provided this copyright notice appears in all copies.
15 // This software is provided "as is" without express or implied
16 // warranty, and with no claim as to its suitability for any purpose.
18 // typedef <implementation-defined> boost::detail::lightweight_mutex;
20 // boost::detail::lightweight_mutex meets the Mutex concept requirements
21 // See http://www.boost.org/libs/thread/doc/mutex_concept.html#Mutex
23 // * Used by the smart pointer library
24 // * Performance oriented
25 // * Header-only implementation
26 // * Small memory footprint
27 // * Not a general purpose mutex, use boost::mutex, CRITICAL_SECTION or
28 // pthread_mutex instead.
29 // * Never spin in a tight lock/do-something/unlock loop, since
30 // lightweight_mutex does not guarantee fairness.
31 // * Never keep a lightweight_mutex locked for long periods.
34 // Note: lwm_linux.hpp has been disabled by default; see the comments
35 // inside for more info.
38 #include <boost/config.hpp>
41 // Note to implementors: if you write a platform-specific lightweight_mutex
42 // for a platform that supports pthreads, be sure to test its performance
43 // against the pthreads-based version using shared_ptr_timing_test.cpp and
44 // shared_ptr_mt_test.cpp. Custom versions are usually not worth the trouble
45 // _unless_ the performance gains are substantial.
47 // Be sure to compare against a "real" pthreads library;
48 // shared_ptr_timing_test.cpp will compile succesfully with a stub do-nothing
49 // pthreads library, since it doesn't create any threads.
52 #ifndef BOOST_HAS_THREADS
53 # include <boost/detail/lwm_nop.hpp>
54 #elif defined(BOOST_USE_ASM_ATOMIC_H)
55 # include <boost/detail/lwm_linux.hpp>
56 #elif defined(BOOST_LWM_USE_CRITICAL_SECTION)
57 # include <boost/detail/lwm_win32_cs.hpp>
58 #elif defined(BOOST_LWM_USE_PTHREADS)
59 # include <boost/detail/lwm_pthreads.hpp>
60 #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
61 # include <boost/detail/lwm_win32.hpp>
63 # include <boost/detail/lwm_irix.hpp>
64 #elif defined(__GLIBCPP__)
65 # include <boost/detail/lwm_gcc.hpp>
66 #elif defined(BOOST_HAS_PTHREADS)
67 # define BOOST_LWM_USE_PTHREADS
68 # include <boost/detail/lwm_pthreads.hpp>
70 # include <boost/detail/lwm_nop.hpp>
73 #endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED