| 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_CONDITION_VARIABLE_H |
| 17 |
#define CPPREFERENCE_CONDITION_VARIABLE_H |
| 18 |
|
| 19 |
#if CPPREFERENCE_STDVER>= 2011 |
| 20 |
|
| 21 |
namespace std { |
| 22 |
|
| 23 |
enum class cv_status { |
| 24 |
no_timeout, |
| 25 |
timeout |
| 26 |
}; |
| 27 |
|
| 28 |
class condition_variable { |
| 29 |
public: |
| 30 |
typedef void* native_handle_type; // actually implementation-defined |
| 31 |
|
| 32 |
condition_variable(); |
| 33 |
condition_variable(const condition_variable&) = delete; |
| 34 |
condition_variable& operator=(const condition_variable&) = delete; |
| 35 |
~condition_variable(); |
| 36 |
|
| 37 |
void notify_one(); |
| 38 |
void notify_all(); |
| 39 |
|
| 40 |
void wait(std::unique_lock<std::mutex>& lock); |
| 41 |
|
| 42 |
template<class Predicate> |
| 43 |
void wait(std::unique_lock<std::mutex>& lock, Predicate pred); |
| 44 |
|
| 45 |
template<class Rep, class Period> |
| 46 |
std::cv_status wait_for(std::unique_lock<std::mutex>& lock, |
| 47 |
const std::chrono::duration<Rep, Period>& rel_time); |
| 48 |
|
| 49 |
template<class Rep, class Period, class Predicate> |
| 50 |
bool wait_for(std::unique_lock<std::mutex>& lock, |
| 51 |
const std::chrono::duration<Rep, Period>& rel_time, |
| 52 |
Predicate pred); |
| 53 |
|
| 54 |
template<class Clock, class Duration> |
| 55 |
std::cv_status wait_until(std::unique_lock<std::mutex>& lock, |
| 56 |
const std::chrono::time_point<Clock, Duration>& timeout_time); |
| 57 |
|
| 58 |
template<class Clock, class Duration, class Predicate> |
| 59 |
bool wait_until(std::unique_lock<std::mutex>& lock, |
| 60 |
const std::chrono::time_point<Clock, Duration>& timeout_time, |
| 61 |
Predicate pred); |
| 62 |
|
| 63 |
native_handle_type native_handle(); |
| 64 |
}; |
| 65 |
|
| 66 |
class condition_variable_any { |
| 67 |
public: |
| 68 |
condition_variable_any(); |
| 69 |
condition_variable_any(const condition_variable_any&) = delete; |
| 70 |
condition_variable_any& operator=(const condition_variable_any&) = delete; |
| 71 |
~condition_variable_any(); |
| 72 |
|
| 73 |
void notify_one(); |
| 74 |
void notify_all(); |
| 75 |
|
| 76 |
template<class Lock> |
| 77 |
void wait(Lock& lock); |
| 78 |
|
| 79 |
template<class Lock, class Predicate> |
| 80 |
void wait(Lock& lock, Predicate pred); |
| 81 |
|
| 82 |
template<class Lock, class Rep, class Period> |
| 83 |
std::cv_status wait_for(Lock& lock, |
| 84 |
const std::chrono::duration<Rep, Period>& rel_time); |
| 85 |
|
| 86 |
template<class Lock, class Rep, class Period, class Predicate> |
| 87 |
bool wait_for(Lock& lock, |
| 88 |
const std::chrono::duration<Rep, Period>& rel_time, |
| 89 |
Predicate pred); |
| 90 |
|
| 91 |
template<class Lock, class Clock, class Duration> |
| 92 |
std::cv_status wait_until(Lock& lock, |
| 93 |
const std::chrono::time_point<Clock, Duration>& timeout_time); |
| 94 |
|
| 95 |
template<class Lock, class Clock, class Duration, class Predicate> |
| 96 |
bool wait_until(Lock& lock, |
| 97 |
const std::chrono::time_point<Clock, Duration>& timeout_time, |
| 98 |
Predicate pred); |
| 99 |
}; |
| 100 |
|
| 101 |
void notify_all_at_thread_exit(std::condition_variable& cond, |
| 102 |
std::unique_lock<std::mutex> lk); |
| 103 |
|
| 104 |
} // namespace std |
| 105 |
|
| 106 |
#endif // CPPREFERENCE_STDVER>= 2011 |
| 107 |
|
| 108 |
#endif // CPPREFERENCE_CONDITION_VARIABLE_H |