atomic_count_solaris.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef DAHUA_DETAIL_ATOMIC_COUNT_SOLARIS_HPP_INCLUDED
  2. #define DAHUA_DETAIL_ATOMIC_COUNT_SOLARIS_HPP_INCLUDED
  3. //
  4. // boost/detail/atomic_count_solaris.hpp
  5. // based on: boost/detail/atomic_count_win32.hpp
  6. //
  7. // Copyright (c) 2001-2005 Peter Dimov
  8. // Copyright (c) 2006 Michael van der Westhuizen
  9. //
  10. // Distributed under the Boost Software License, Version 1.0. (See
  11. // accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. //
  14. #include <atomic.h>
  15. namespace Dahua {
  16. namespace Infra {
  17. namespace Detail {
  18. class atomic_count
  19. {
  20. public:
  21. explicit atomic_count( uint32_t v ): value_( v )
  22. {
  23. }
  24. long operator++()
  25. {
  26. return atomic_inc_32_nv( &value_ );
  27. }
  28. long operator--()
  29. {
  30. return atomic_dec_32_nv( &value_ );
  31. }
  32. operator uint32_t() const
  33. {
  34. return static_cast<uint32_t const volatile &>( value_ );
  35. }
  36. uint32_t get() const
  37. {
  38. return static_cast<uint32_t const volatile &>( value_ );
  39. }
  40. void set(uint32_t v)
  41. {
  42. value_v = v;
  43. return;
  44. }
  45. private:
  46. atomic_count( atomic_count const & );
  47. atomic_count & operator=( atomic_count const & );
  48. uint32_t value_;
  49. };
  50. } // namespace Detail
  51. } // namespace Infra
  52. } // namespace Dahua
  53. #endif // #ifndef DAHUA_DETAIL_ATOMIC_COUNT_SOLARIS_HPP_INCLUDED