atomic_count.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
  2. #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. //
  8. // boost/detail/atomic_count.hpp - thread/SMP safe reference counter
  9. //
  10. // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
  11. // Copyright (c) 2013 Peter Dimov
  12. //
  13. // Distributed under the Boost Software License, Version 1.0.
  14. // See accompanying file LICENSE_1_0.txt or copy at
  15. // http://www.boost.org/LICENSE_1_0.txt
  16. //
  17. // typedef <implementation-defined> boost::detail::atomic_count;
  18. //
  19. // atomic_count a(n);
  20. //
  21. // (n is convertible to long)
  22. //
  23. // Effects: Constructs an atomic_count with an initial value of n
  24. //
  25. // a;
  26. //
  27. // Returns: (long) the current value of a
  28. // Memory Ordering: acquire
  29. //
  30. // ++a;
  31. //
  32. // Effects: Atomically increments the value of a
  33. // Returns: (long) the new value of a
  34. // Memory Ordering: acquire/release
  35. //
  36. // --a;
  37. //
  38. // Effects: Atomically decrements the value of a
  39. // Returns: (long) the new value of a
  40. // Memory Ordering: acquire/release
  41. //
  42. #include <boost/smart_ptr/detail/deprecated_macros.hpp>
  43. #if defined( BOOST_AC_DISABLE_THREADS )
  44. # include <boost/smart_ptr/detail/atomic_count_nt.hpp>
  45. #elif defined( BOOST_AC_USE_STD_ATOMIC )
  46. # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp>
  47. #elif defined( BOOST_SP_DISABLE_THREADS )
  48. # include <boost/smart_ptr/detail/atomic_count_nt.hpp>
  49. #else
  50. # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp>
  51. #endif
  52. #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED