| 1 |
/* Copyright (C) 2015 Povilas Kanapickas <[email protected]> |
| 2 |
|
| 3 |
This file is part of cppreference-doc |
| 4 |
|
| 5 |
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 |
| 6 |
Unported License. To view a copy of this license, visit |
| 7 |
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative |
| 8 |
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. |
| 9 |
|
| 10 |
Permission is granted to copy, distribute and/or modify this document |
| 11 |
under the terms of the GNU Free Documentation License, Version 1.3 or |
| 12 |
any later version published by the Free Software Foundation; with no |
| 13 |
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. |
| 14 |
*/ |
| 15 |
|
| 16 |
#ifndef CPPREFERENCE_SHARED_MUTEX_H |
| 17 |
#define CPPREFERENCE_SHARED_MUTEX_H |
| 18 |
|
| 19 |
#if CPPREFERENCE_STDVER>= 2014 |
| 20 |
|
| 21 |
namespace std { |
| 22 |
|
| 23 |
#if CPPREFERENCE_STDVER>= 2017 |
| 24 |
class shared_mutex { |
| 25 |
public: |
| 26 |
typedef void* native_handle_type; // actually impl-defined |
| 27 |
|
| 28 |
shared_mutex(); |
| 29 |
shared_mutex(const shared_mutex&) = delete; |
| 30 |
shared_mutex& operator=(const shared_mutex&) = delete; |
| 31 |
|
| 32 |
~shared_mutex(); |
| 33 |
|
| 34 |
void lock(); |
| 35 |
bool try_lock(); |
| 36 |
void unlock(); |
| 37 |
|
| 38 |
void lock_shared(); |
| 39 |
bool try_lock_shared(); |
| 40 |
void unlock_shared(); |
| 41 |
native_handle_type native_handle(); |
| 42 |
}; |
| 43 |
#endif // CPPREFERENCE_STDVER>= 2017 |
| 44 |
|
| 45 |
class shared_timed_mutex { |
| 46 |
public: |
| 47 |
typedef void* native_handle_type; // actually impl-defined |
| 48 |
|
| 49 |
shared_timed_mutex(); |
| 50 |
shared_timed_mutex(const shared_timed_mutex&) = delete; |
| 51 |
shared_timed_mutex& operator=(const shared_timed_mutex&) = delete; |
| 52 |
|
| 53 |
~shared_timed_mutex(); |
| 54 |
|
| 55 |
void lock(); |
| 56 |
bool try_lock(); |
| 57 |
template<class Rep, class Period> |
| 58 |
bool try_lock_for(const std::chrono::duration<Rep, Period>& timeout_duration); |
| 59 |
template<class Clock, class Duration> |
| 60 |
bool try_lock_until(const std::chrono::time_point<Clock, Duration>& timeout_time); |
| 61 |
void unlock(); |
| 62 |
|
| 63 |
void lock_shared(); |
| 64 |
bool try_lock_shared(); |
| 65 |
|
| 66 |
template<class Rep, class Period> |
| 67 |
bool try_lock_shared_for(const std::chrono::duration<Rep, Period>& timeout_duration); |
| 68 |
template<class Clock, class Duration> |
| 69 |
bool try_lock_shared_until(const std::chrono::time_point<Clock, Duration>& timeout_time); |
| 70 |
|
| 71 |
void unlock_shared(); |
| 72 |
native_handle_type native_handle(); |
| 73 |
}; |
| 74 |
|
| 75 |
template<class Mutex> |
| 76 |
class shared_lock { |
| 77 |
public: |
| 78 |
typedef Mutex mutex_type; |
| 79 |
|
| 80 |
shared_lock(); |
| 81 |
shared_lock(shared_lock&& other); |
| 82 |
explicit shared_lock(mutex_type& m); |
| 83 |
shared_lock(mutex_type& m, std::defer_lock_t t); |
| 84 |
shared_lock(mutex_type& m, std::try_to_lock_t t); |
| 85 |
shared_lock(mutex_type& m, std::adopt_lock_t t); |
| 86 |
|
| 87 |
template<class Rep, class Period> |
| 88 |
shared_lock(mutex_type& m, |
| 89 |
const std::chrono::duration<Rep, Period>& timeout_duration); |
| 90 |
|
| 91 |
template<class Clock, class Duration> |
| 92 |
shared_lock(mutex_type& m, |
| 93 |
const std::chrono::time_point<Clock, Duration>& timeout_time); |
| 94 |
|
| 95 |
~shared_lock(); |
| 96 |
shared_lock& operator=(shared_lock&& other); |
| 97 |
|
| 98 |
void lock(); |
| 99 |
bool try_lock(); |
| 100 |
template<class Rep, class Period> |
| 101 |
bool try_lock_for(const std::chrono::duration<Rep, Period>& timeout_duration); |
| 102 |
template<class Clock, class Duration> |
| 103 |
bool try_lock_until(const std::chrono::time_point<Clock, Duration>& timeout_time); |
| 104 |
void unlock(); |
| 105 |
|
| 106 |
void swap(shared_lock<Mutex>& other); |
| 107 |
|
| 108 |
mutex_type* release(); |
| 109 |
mutex_type* mutex() const; |
| 110 |
bool owns_lock() const; |
| 111 |
explicit operator bool() const; |
| 112 |
}; |
| 113 |
|
| 114 |
template<class Mutex> |
| 115 |
void swap(shared_lock<Mutex>& lhs, |
| 116 |
shared_lock<Mutex>& rhs); |
| 117 |
|
| 118 |
} // namespace std |
| 119 |
|
| 120 |
#endif // CPPREFERENCE_STDVER>= 2014 |
| 121 |
|
| 122 |
#endif // CPPREFERENCE_SHARED_MUTEX_H |