null_mutex.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #
  16. #if defined(BOOST_HAS_PRAGMA_ONCE)
  17. # pragma once
  18. #endif
  19. #include <boost/interprocess/detail/config_begin.hpp>
  20. #include <boost/interprocess/detail/workaround.hpp>
  21. //!\file
  22. //!Describes null_mutex classes
  23. namespace boost {
  24. #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
  25. namespace posix_time
  26. { class ptime; }
  27. #endif //#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
  28. namespace interprocess {
  29. //!Implements a mutex that simulates a mutex without doing any operation and
  30. //!simulates a successful operation.
  31. class null_mutex
  32. {
  33. #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
  34. null_mutex(const null_mutex&);
  35. null_mutex &operator= (const null_mutex&);
  36. #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
  37. public:
  38. //!Constructor.
  39. //!Empty.
  40. null_mutex(){}
  41. //!Destructor.
  42. //!Empty.
  43. ~null_mutex(){}
  44. //!Simulates a mutex lock() operation. Empty function.
  45. void lock(){}
  46. //!Simulates a mutex try_lock() operation.
  47. //!Equivalent to "return true;"
  48. bool try_lock()
  49. { return true; }
  50. //!Simulates a mutex timed_lock() operation.
  51. //!Equivalent to "return true;"
  52. bool timed_lock(const boost::posix_time::ptime &)
  53. { return true; }
  54. //!Simulates a mutex unlock() operation.
  55. //!Empty function.
  56. void unlock(){}
  57. //!Simulates a mutex lock_sharable() operation.
  58. //!Empty function.
  59. void lock_sharable(){}
  60. //!Simulates a mutex try_lock_sharable() operation.
  61. //!Equivalent to "return true;"
  62. bool try_lock_sharable()
  63. { return true; }
  64. //!Simulates a mutex timed_lock_sharable() operation.
  65. //!Equivalent to "return true;"
  66. bool timed_lock_sharable(const boost::posix_time::ptime &)
  67. { return true; }
  68. //!Simulates a mutex unlock_sharable() operation.
  69. //!Empty function.
  70. void unlock_sharable(){}
  71. //!Simulates a mutex lock_upgradable() operation.
  72. //!Empty function.
  73. void lock_upgradable(){}
  74. //!Simulates a mutex try_lock_upgradable() operation.
  75. //!Equivalent to "return true;"
  76. bool try_lock_upgradable()
  77. { return true; }
  78. //!Simulates a mutex timed_lock_upgradable() operation.
  79. //!Equivalent to "return true;"
  80. bool timed_lock_upgradable(const boost::posix_time::ptime &)
  81. { return true; }
  82. //!Simulates a mutex unlock_upgradable() operation.
  83. //!Empty function.
  84. void unlock_upgradable(){}
  85. //!Simulates unlock_and_lock_upgradable().
  86. //!Empty function.
  87. void unlock_and_lock_upgradable(){}
  88. //!Simulates unlock_and_lock_sharable().
  89. //!Empty function.
  90. void unlock_and_lock_sharable(){}
  91. //!Simulates unlock_upgradable_and_lock_sharable().
  92. //!Empty function.
  93. void unlock_upgradable_and_lock_sharable(){}
  94. //Promotions
  95. //!Simulates unlock_upgradable_and_lock().
  96. //!Empty function.
  97. void unlock_upgradable_and_lock(){}
  98. //!Simulates try_unlock_upgradable_and_lock().
  99. //!Equivalent to "return true;"
  100. bool try_unlock_upgradable_and_lock()
  101. { return true; }
  102. //!Simulates timed_unlock_upgradable_and_lock().
  103. //!Equivalent to "return true;"
  104. bool timed_unlock_upgradable_and_lock(const boost::posix_time::ptime &)
  105. { return true; }
  106. //!Simulates try_unlock_sharable_and_lock().
  107. //!Equivalent to "return true;"
  108. bool try_unlock_sharable_and_lock()
  109. { return true; }
  110. //!Simulates try_unlock_sharable_and_lock_upgradable().
  111. //!Equivalent to "return true;"
  112. bool try_unlock_sharable_and_lock_upgradable()
  113. { return true; }
  114. };
  115. } //namespace interprocess {
  116. } //namespace boost {
  117. #include <boost/interprocess/detail/config_end.hpp>
  118. #endif //BOOST_INTERPROCESS_NULL_MUTEX_HPP