null_mutex.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/interprocess for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_INTERPROCESS_NULL_MUTEX_HPP
  11. #define BOOST_INTERPROCESS_NULL_MUTEX_HPP
  12. #if (defined _MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif
  15. #include <boost/interprocess/detail/config_begin.hpp>
  16. #include <boost/interprocess/detail/workaround.hpp>
  17. //!\file
  18. //!Describes null_mutex classes
  19. namespace boost {
  20. namespace posix_time
  21. { class ptime; }
  22. namespace interprocess {
  23. //!Implements a mutex that simulates a mutex without doing any operation and
  24. //!simulates a successful operation.
  25. class null_mutex
  26. {
  27. /// @cond
  28. null_mutex(const null_mutex&);
  29. null_mutex &operator= (const null_mutex&);
  30. /// @endcond
  31. public:
  32. //!Constructor.
  33. //!Empty.
  34. null_mutex(){}
  35. //!Destructor.
  36. //!Empty.
  37. ~null_mutex(){}
  38. //!Simulates a mutex lock() operation. Empty function.
  39. void lock(){}
  40. //!Simulates a mutex try_lock() operation.
  41. //!Equivalent to "return true;"
  42. bool try_lock()
  43. { return true; }
  44. //!Simulates a mutex timed_lock() operation.
  45. //!Equivalent to "return true;"
  46. bool timed_lock(const boost::posix_time::ptime &)
  47. { return true; }
  48. //!Simulates a mutex unlock() operation.
  49. //!Empty function.
  50. void unlock(){}
  51. //!Simulates a mutex lock_sharable() operation.
  52. //!Empty function.
  53. void lock_sharable(){}
  54. //!Simulates a mutex try_lock_sharable() operation.
  55. //!Equivalent to "return true;"
  56. bool try_lock_sharable()
  57. { return true; }
  58. //!Simulates a mutex timed_lock_sharable() operation.
  59. //!Equivalent to "return true;"
  60. bool timed_lock_sharable(const boost::posix_time::ptime &)
  61. { return true; }
  62. //!Simulates a mutex unlock_sharable() operation.
  63. //!Empty function.
  64. void unlock_sharable(){}
  65. //!Simulates a mutex lock_upgradable() operation.
  66. //!Empty function.
  67. void lock_upgradable(){}
  68. //!Simulates a mutex try_lock_upgradable() operation.
  69. //!Equivalent to "return true;"
  70. bool try_lock_upgradable()
  71. { return true; }
  72. //!Simulates a mutex timed_lock_upgradable() operation.
  73. //!Equivalent to "return true;"
  74. bool timed_lock_upgradable(const boost::posix_time::ptime &)
  75. { return true; }
  76. //!Simulates a mutex unlock_upgradable() operation.
  77. //!Empty function.
  78. void unlock_upgradable(){}
  79. //!Simulates unlock_and_lock_upgradable().
  80. //!Empty function.
  81. void unlock_and_lock_upgradable(){}
  82. //!Simulates unlock_and_lock_sharable().
  83. //!Empty function.
  84. void unlock_and_lock_sharable(){}
  85. //!Simulates unlock_upgradable_and_lock_sharable().
  86. //!Empty function.
  87. void unlock_upgradable_and_lock_sharable(){}
  88. //Promotions
  89. //!Simulates unlock_upgradable_and_lock().
  90. //!Empty function.
  91. void unlock_upgradable_and_lock(){}
  92. //!Simulates try_unlock_upgradable_and_lock().
  93. //!Equivalent to "return true;"
  94. bool try_unlock_upgradable_and_lock()
  95. { return true; }
  96. //!Simulates timed_unlock_upgradable_and_lock().
  97. //!Equivalent to "return true;"
  98. bool timed_unlock_upgradable_and_lock(const boost::posix_time::ptime &)
  99. { return true; }
  100. //!Simulates try_unlock_sharable_and_lock().
  101. //!Equivalent to "return true;"
  102. bool try_unlock_sharable_and_lock()
  103. { return true; }
  104. //!Simulates try_unlock_sharable_and_lock_upgradable().
  105. //!Equivalent to "return true;"
  106. bool try_unlock_sharable_and_lock_upgradable()
  107. { return true; }
  108. };
  109. } //namespace interprocess {
  110. } //namespace boost {
  111. #include <boost/interprocess/detail/config_end.hpp>
  112. #endif //BOOST_INTERPROCESS_NULL_MUTEX_HPP