YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
mutex_event.cpp
Go to the documentation of this file.
1
#include <
yaclib/util/detail/mutex_event.hpp
>
2
3
namespace
yaclib::detail
{
4
5
MutexEvent::Token
MutexEvent::Make
()
noexcept
{
6
return
Token
{_m};
7
}
8
9
void
MutexEvent::Wait
(
Token
&
token
)
noexcept
{
10
while
(!_is_ready) {
11
_cv.wait(
token
);
12
}
13
}
14
15
void
MutexEvent::Set
()
noexcept
{
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
21
void
MutexEvent::Reset
()
noexcept
{
22
_is_ready =
false
;
23
}
24
25
}
// namespace yaclib::detail
yaclib::detail::MutexEvent::Set
void Set() noexcept
Definition
mutex_event.cpp:15
yaclib::detail::MutexEvent::Token
std::unique_lock< yaclib_std::mutex > Token
Definition
mutex_event.hpp:13
yaclib::detail::MutexEvent::Wait
void Wait(Token &token) noexcept
Definition
mutex_event.cpp:9
yaclib::detail::MutexEvent::Reset
void Reset() noexcept
Definition
mutex_event.cpp:21
yaclib::detail::MutexEvent::Make
Token Make() noexcept
Definition
mutex_event.cpp:5
mutex_event.hpp
yaclib::detail
Definition
base_core.hpp:18
yaclib::MakeContract
Contract< V, E > MakeContract()
Creates related future and promise.
Definition
contract.hpp:25
src
util
mutex_event.cpp
Generated by
1.9.8