1 #ifndef BOOST_DETAIL_ATOMIC_COUNT_PTHREADS_HPP_INCLUDED
2 #define BOOST_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 // Permission to copy, use, modify, sell and distribute this software
10 // is granted provided this copyright notice appears in all copies.
11 // This software is provided "as is" without express or implied
12 // warranty, and with no claim as to its suitability for any purpose.
18 // The generic pthread_mutex-based implementation sometimes leads to
19 // inefficiencies. Example: a class with two atomic_count members
20 // can get away with a single mutex.
22 // Users can detect this situation by checking BOOST_AC_USE_PTHREADS.
39 scoped_lock(pthread_mutex_t & m): m_(m)
41 pthread_mutex_lock(&m_);
46 pthread_mutex_unlock(&m_);
56 explicit atomic_count(long v): value_(v)
58 pthread_mutex_init(&mutex_, 0);
63 pthread_mutex_destroy(&mutex_);
68 scoped_lock lock(mutex_);
74 scoped_lock lock(mutex_);
80 scoped_lock lock(mutex_);
86 atomic_count(atomic_count const &);
87 atomic_count & operator=(atomic_count const &);
89 mutable pthread_mutex_t mutex_;
97 #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_PTHREADS_HPP_INCLUDED