1 #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_PTHREADS_HPP_INCLUDED
2 #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_PTHREADS_HPP_INCLUDED
5 // boost/detail/atomic_count_pthreads.hpp
7 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
14 #include <boost/assert.hpp>
17 #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
19 #include <boost/config/pragma_message.hpp>
20 BOOST_PRAGMA_MESSAGE("Using pthread_mutex atomic_count")
25 // The generic pthread_mutex-based implementation sometimes leads to
26 // inefficiencies. Example: a class with two atomic_count members
27 // can get away with a single mutex.
29 // Users can detect this situation by checking BOOST_AC_USE_PTHREADS.
46 scoped_lock(pthread_mutex_t & m): m_(m)
48 BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
53 BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
63 explicit atomic_count(long v): value_(v)
65 BOOST_VERIFY( pthread_mutex_init( &mutex_, 0 ) == 0 );
70 BOOST_VERIFY( pthread_mutex_destroy( &mutex_ ) == 0 );
75 scoped_lock lock(mutex_);
81 scoped_lock lock(mutex_);
87 scoped_lock lock(mutex_);
93 atomic_count(atomic_count const &);
94 atomic_count & operator=(atomic_count const &);
96 mutable pthread_mutex_t mutex_;
100 } // namespace detail
104 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_PTHREADS_HPP_INCLUDED