atomic_count_nt.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED
  2. #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED
  3. //
  4. // boost/detail/atomic_count_nt.hpp
  5. //
  6. // Trivial atomic_count for the single-threaded case
  7. //
  8. // http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html
  9. //
  10. // Copyright 2013 Peter Dimov
  11. //
  12. // Distributed under the Boost Software License, Version 1.0.
  13. // See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt
  15. //
  16. #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
  17. #include <boost/config/pragma_message.hpp>
  18. BOOST_PRAGMA_MESSAGE("Using single-threaded, non-atomic atomic_count")
  19. #endif
  20. namespace boost
  21. {
  22. namespace detail
  23. {
  24. class atomic_count
  25. {
  26. public:
  27. explicit atomic_count( long v ): value_( v )
  28. {
  29. }
  30. long operator++()
  31. {
  32. return ++value_;
  33. }
  34. long operator--()
  35. {
  36. return --value_;
  37. }
  38. operator long() const
  39. {
  40. return value_;
  41. }
  42. private:
  43. atomic_count(atomic_count const &);
  44. atomic_count & operator=(atomic_count const &);
  45. long value_;
  46. };
  47. } // namespace detail
  48. } // namespace boost
  49. #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED