atomic_count_sync.hpp
Go to the documentation of this file.
00001 #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED
00002 #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED
00003 
00004 //
00005 //  boost/detail/atomic_count_sync.hpp
00006 //
00007 //  atomic_count for g++ 4.1+
00008 //
00009 //  http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html
00010 //
00011 //  Copyright 2007 Peter Dimov
00012 //
00013 //  Distributed under the Boost Software License, Version 1.0. (See
00014 //  accompanying file LICENSE_1_0.txt or copy at
00015 //  http://www.boost.org/LICENSE_1_0.txt)
00016 //
00017 
00018 #if defined( __ia64__ ) && defined( __INTEL_COMPILER )
00019 # include <ia64intrin.h>
00020 #endif
00021 
00022 namespace boost
00023 {
00024 
00025 namespace detail
00026 {
00027 
00028 class atomic_count
00029 {
00030 public:
00031 
00032     explicit atomic_count( long v ) : value_( v ) {}
00033 
00034     long operator++()
00035     {
00036         return __sync_add_and_fetch( &value_, 1 );
00037     }
00038 
00039     long operator--()
00040     {
00041         return __sync_add_and_fetch( &value_, -1 );
00042     }
00043 
00044     operator long() const
00045     {
00046         return __sync_fetch_and_add( &value_, 0 );
00047     }
00048 
00049 private:
00050 
00051     atomic_count(atomic_count const &);
00052     atomic_count & operator=(atomic_count const &);
00053 
00054     mutable long value_;
00055 };
00056 
00057 } // namespace detail
00058 
00059 } // namespace boost
00060 
00061 #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:28