30#ifndef _GLIBCXX_UNIQUE_LOCK_H
31#define _GLIBCXX_UNIQUE_LOCK_H 1
34#pragma GCC system_header
37#if __cplusplus < 201103L
46namespace std _GLIBCXX_VISIBILITY(default)
48_GLIBCXX_BEGIN_NAMESPACE_VERSION
61 template<
typename _Mutex>
68 : _M_device(0), _M_owns(
false)
95 template<
typename _Clock,
typename _Duration>
100 _M_owns(_M_device->try_lock_until(
__atime))
103 template<
typename _Rep,
typename _Period>
108 _M_owns(_M_device->try_lock_for(
__rtime))
121 : _M_device(
__u._M_device), _M_owns(
__u._M_owns)
139 __throw_system_error(
int(errc::operation_not_permitted));
141 __throw_system_error(
int(errc::resource_deadlock_would_occur));
154 __throw_system_error(
int(errc::operation_not_permitted));
156 __throw_system_error(
int(errc::resource_deadlock_would_occur));
159 _M_owns = _M_device->try_lock();
164 template<
typename _Clock,
typename _Duration>
170 __throw_system_error(
int(errc::operation_not_permitted));
172 __throw_system_error(
int(errc::resource_deadlock_would_occur));
175 _M_owns = _M_device->try_lock_until(
__atime);
180 template<
typename _Rep,
typename _Period>
186 __throw_system_error(
int(errc::operation_not_permitted));
188 __throw_system_error(
int(errc::resource_deadlock_would_occur));
191 _M_owns = _M_device->try_lock_for(
__rtime);
200 __throw_system_error(
int(errc::operation_not_permitted));
211 std::swap(_M_device,
__u._M_device);
212 std::swap(_M_owns,
__u._M_owns);
218 mutex_type*
__ret = _M_device;
226 owns_lock()
const noexcept
229 explicit operator bool()
const noexcept
230 {
return owns_lock(); }
234 mutex()
const noexcept
235 {
return _M_device; }
238 mutex_type* _M_device;
244 template<
typename _Mutex>
249_GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
ISO C++ entities toplevel namespace is std.
chrono::duration represents a distance between two points in time
chrono::time_point represents a point in time as measured by a clock
Do not acquire ownership of the mutex.
Try to acquire ownership of the mutex without blocking.
Assume the calling thread has already obtained mutex ownership and manage it.
A movable scoped lock type.
void swap(unique_lock< _Mutex > &__x, unique_lock< _Mutex > &__y) noexcept
Swap overload for unique_lock objects.