atomic_count.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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/config.hpp>
  43. #include <boost/smart_ptr/detail/sp_has_sync.hpp>
  44. #if defined( BOOST_AC_DISABLE_THREADS )
  45. # include <boost/smart_ptr/detail/atomic_count_nt.hpp>
  46. #elif defined( BOOST_AC_USE_STD_ATOMIC )
  47. # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp>
  48. #elif defined( BOOST_AC_USE_SPINLOCK )
  49. # include <boost/smart_ptr/detail/atomic_count_spin.hpp>
  50. #elif defined( BOOST_AC_USE_PTHREADS )
  51. # include <boost/smart_ptr/detail/atomic_count_pt.hpp>
  52. #elif defined( BOOST_SP_DISABLE_THREADS )
  53. # include <boost/smart_ptr/detail/atomic_count_nt.hpp>
  54. #elif defined( BOOST_SP_USE_STD_ATOMIC )
  55. # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp>
  56. #elif defined( BOOST_SP_USE_SPINLOCK )
  57. # include <boost/smart_ptr/detail/atomic_count_spin.hpp>
  58. #elif defined( BOOST_SP_USE_PTHREADS )
  59. # include <boost/smart_ptr/detail/atomic_count_pt.hpp>
  60. #elif defined( BOOST_DISABLE_THREADS ) && !defined( BOOST_SP_ENABLE_THREADS ) && !defined( BOOST_DISABLE_WIN32 )
  61. # include <boost/smart_ptr/detail/atomic_count_nt.hpp>
  62. #elif !defined( BOOST_NO_CXX11_HDR_ATOMIC )
  63. # include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp>
  64. #elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) && !defined( __PATHSCALE__ )
  65. # include <boost/smart_ptr/detail/atomic_count_gcc_x86.hpp>
  66. #elif defined( BOOST_SP_HAS_SYNC )
  67. # include <boost/smart_ptr/detail/atomic_count_sync.hpp>
  68. #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
  69. # include <boost/smart_ptr/detail/atomic_count_win32.hpp>
  70. #elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
  71. # include <boost/smart_ptr/detail/atomic_count_gcc.hpp>
  72. #elif !defined( BOOST_HAS_THREADS )
  73. # include <boost/smart_ptr/detail/atomic_count_nt.hpp>
  74. #else
  75. # include <boost/smart_ptr/detail/atomic_count_spin.hpp>
  76. #endif
  77. #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED