atomic_count_nt.hpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. namespace boost
  17. {
  18. namespace detail
  19. {
  20. class atomic_count
  21. {
  22. public:
  23. explicit atomic_count( long v ): value_( v )
  24. {
  25. }
  26. long operator++()
  27. {
  28. return ++value_;
  29. }
  30. long operator--()
  31. {
  32. return --value_;
  33. }
  34. operator long() const
  35. {
  36. return value_;
  37. }
  38. private:
  39. atomic_count(atomic_count const &);
  40. atomic_count & operator=(atomic_count const &);
  41. long value_;
  42. };
  43. } // namespace detail
  44. } // namespace boost
  45. #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED