YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
mutex_event.cpp
Go to the documentation of this file.
2
3namespace yaclib::detail {
4
8
9void MutexEvent::Wait(Token& token) noexcept {
10 while (!_is_ready) {
11 _cv.wait(token);
12 }
13}
14
16 std::lock_guard lock{_m};
17 _is_ready = true;
18 _cv.notify_one(); // Notify under mutex, because cv located on stack memory of other thread
19}
20
22 _is_ready = false;
23}
24
25} // namespace yaclib::detail
std::unique_lock< yaclib_std::mutex > Token
void Wait(Token &token) noexcept
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25