mutexes.qbk 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. [/
  2. (C) Copyright 2007-11 Anthony Williams
  3. (C) Copyright 2011-12 Vicente J. Botet Escriba
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt).
  7. ]
  8. [section:mutex_types Mutex Types]
  9. [section:mutex Class `mutex`]
  10. #include <boost/thread/mutex.hpp>
  11. class mutex:
  12. boost::noncopyable
  13. {
  14. public:
  15. mutex();
  16. ~mutex();
  17. void lock();
  18. bool try_lock();
  19. void unlock();
  20. typedef platform-specific-type native_handle_type;
  21. native_handle_type native_handle();
  22. typedef unique_lock<mutex> scoped_lock;
  23. typedef unspecified-type scoped_try_lock;
  24. };
  25. __mutex__ implements the __lockable_concept__ to provide an exclusive-ownership mutex. At most one thread can own the lock on a given
  26. instance of __mutex__ at any time. Multiple concurrent calls to __lock_ref__, __try_lock_ref__ and __unlock_ref__ shall be permitted.
  27. [section:nativehandle Member function `native_handle()`]
  28. typedef platform-specific-type native_handle_type;
  29. native_handle_type native_handle();
  30. [variablelist
  31. [[Effects:] [Returns an instance of `native_handle_type` that can be used with platform-specific APIs to manipulate the underlying
  32. implementation. If no such instance exists, `native_handle()` and `native_handle_type` are not present.]]
  33. [[Throws:] [Nothing.]]
  34. ]
  35. [endsect]
  36. [endsect]
  37. [section:try_mutex Typedef `try_mutex`]
  38. #include <boost/thread/mutex.hpp>
  39. typedef mutex try_mutex;
  40. __try_mutex__ is a `typedef` to __mutex__, provided for backwards compatibility with previous releases of boost.
  41. [endsect]
  42. [section:timed_mutex Class `timed_mutex`]
  43. #include <boost/thread/mutex.hpp>
  44. class timed_mutex:
  45. boost::noncopyable
  46. {
  47. public:
  48. timed_mutex();
  49. ~timed_mutex();
  50. void lock();
  51. void unlock();
  52. bool try_lock();
  53. template <class Rep, class Period>
  54. bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
  55. template <class Clock, class Duration>
  56. bool try_lock_until(const chrono::time_point<Clock, Duration>& t);
  57. typedef platform-specific-type native_handle_type;
  58. native_handle_type native_handle();
  59. typedef unique_lock<timed_mutex> scoped_timed_lock;
  60. typedef unspecified-type scoped_try_lock;
  61. typedef scoped_timed_lock scoped_lock;
  62. #if defined BOOST_THREAD_PROVIDES_DATE_TIME || defined BOOST_THREAD_DONT_USE_CHRONO
  63. bool timed_lock(system_time const & abs_time);
  64. template<typename TimeDuration>
  65. bool timed_lock(TimeDuration const & relative_time);
  66. #endif
  67. };
  68. __timed_mutex__ implements the __timed_lockable_concept__ to provide an exclusive-ownership mutex. At most one thread can own the
  69. lock on a given instance of __timed_mutex__ at any time. Multiple concurrent calls to __lock_ref__, __try_lock_ref__,
  70. __timed_lock_ref__, __timed_lock_duration_ref__ and __unlock_ref__ shall be permitted.
  71. [section:nativehandle Member function `native_handle()`]
  72. typedef platform-specific-type native_handle_type;
  73. native_handle_type native_handle();
  74. [variablelist
  75. [[Effects:] [Returns an instance of `native_handle_type` that can be used with platform-specific APIs to manipulate the underlying
  76. implementation. If no such instance exists, `native_handle()` and `native_handle_type` are not present.]]
  77. [[Throws:] [Nothing.]]
  78. ]
  79. [endsect]
  80. [endsect]
  81. [section:recursive_mutex Class `recursive_mutex`]
  82. #include <boost/thread/recursive_mutex.hpp>
  83. class recursive_mutex:
  84. boost::noncopyable
  85. {
  86. public:
  87. recursive_mutex();
  88. ~recursive_mutex();
  89. void lock();
  90. bool try_lock() noexcept;
  91. void unlock();
  92. typedef platform-specific-type native_handle_type;
  93. native_handle_type native_handle();
  94. typedef unique_lock<recursive_mutex> scoped_lock;
  95. typedef unspecified-type scoped_try_lock;
  96. };
  97. __recursive_mutex__ implements the __lockable_concept__ to provide an exclusive-ownership recursive mutex. At most one thread can
  98. own the lock on a given instance of __recursive_mutex__ at any time. Multiple concurrent calls to __lock_ref__, __try_lock_ref__ and
  99. __unlock_ref__ shall be permitted. A thread that already has exclusive ownership of a given __recursive_mutex__ instance can call
  100. __lock_ref__ or __try_lock_ref__ to acquire an additional level of ownership of the mutex. __unlock_ref__ must be called once for
  101. each level of ownership acquired by a single thread before ownership can be acquired by another thread.
  102. [section:nativehandle Member function `native_handle()`]
  103. typedef platform-specific-type native_handle_type;
  104. native_handle_type native_handle();
  105. [variablelist
  106. [[Effects:] [Returns an instance of `native_handle_type` that can be used with platform-specific APIs to manipulate the underlying
  107. implementation. If no such instance exists, `native_handle()` and `native_handle_type` are not present.]]
  108. [[Throws:] [Nothing.]]
  109. ]
  110. [endsect]
  111. [endsect]
  112. [section:recursive_try_mutex Typedef `recursive_try_mutex`]
  113. #include <boost/thread/recursive_mutex.hpp>
  114. typedef recursive_mutex recursive_try_mutex;
  115. __recursive_try_mutex__ is a `typedef` to __recursive_mutex__, provided for backwards compatibility with previous releases of boost.
  116. [endsect]
  117. [section:recursive_timed_mutex Class `recursive_timed_mutex`]
  118. #include <boost/thread/recursive_mutex.hpp>
  119. class recursive_timed_mutex:
  120. boost::noncopyable
  121. {
  122. public:
  123. recursive_timed_mutex();
  124. ~recursive_timed_mutex();
  125. void lock();
  126. bool try_lock() noexcept;
  127. void unlock();
  128. template <class Rep, class Period>
  129. bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
  130. template <class Clock, class Duration>
  131. bool try_lock_until(const chrono::time_point<Clock, Duration>& t);
  132. typedef platform-specific-type native_handle_type;
  133. native_handle_type native_handle();
  134. typedef unique_lock<recursive_timed_mutex> scoped_lock;
  135. typedef unspecified-type scoped_try_lock;
  136. typedef scoped_lock scoped_timed_lock;
  137. #if defined BOOST_THREAD_PROVIDES_DATE_TIME || defined BOOST_THREAD_DONT_USE_CHRONO
  138. bool timed_lock(system_time const & abs_time);
  139. template<typename TimeDuration>
  140. bool timed_lock(TimeDuration const & relative_time);
  141. #endif
  142. };
  143. __recursive_timed_mutex__ implements the __timed_lockable_concept__ to provide an exclusive-ownership recursive mutex. At most one
  144. thread can own the lock on a given instance of __recursive_timed_mutex__ at any time. Multiple concurrent calls to __lock_ref__,
  145. __try_lock_ref__, __timed_lock_ref__, __timed_lock_duration_ref__ and __unlock_ref__ shall be permitted. A thread that already has
  146. exclusive ownership of a given __recursive_timed_mutex__ instance can call __lock_ref__, __timed_lock_ref__,
  147. __timed_lock_duration_ref__ or __try_lock_ref__ to acquire an additional level of ownership of the mutex. __unlock_ref__ must be
  148. called once for each level of ownership acquired by a single thread before ownership can be acquired by another thread.
  149. [section:nativehandle Member function `native_handle()`]
  150. typedef platform-specific-type native_handle_type;
  151. native_handle_type native_handle();
  152. [variablelist
  153. [[Effects:] [Returns an instance of `native_handle_type` that can be used with platform-specific APIs to manipulate the underlying
  154. implementation. If no such instance exists, `native_handle()` and `native_handle_type` are not present.]]
  155. [[Throws:] [Nothing.]]
  156. ]
  157. [endsect]
  158. [endsect]
  159. [include shared_mutex_ref.qbk]
  160. [endsect]