YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
mutex.cpp
Go to the documentation of this file.
1
#include <
yaclib/fault/detail/fiber/mutex.hpp
>
2
3
namespace
yaclib::detail::fiber
{
4
5
void
Mutex::lock
() {
6
while
(
_occupied
) {
7
_queue
.
Wait
(
NoTimeoutTag
{});
8
}
9
_occupied
=
true
;
10
}
11
12
bool
Mutex::try_lock
()
noexcept
{
13
if
(
_occupied
) {
14
return
false
;
15
}
16
_occupied
=
true
;
17
return
true
;
18
}
19
20
void
Mutex::unlock
()
noexcept
{
21
_occupied
=
false
;
22
_queue
.
NotifyOne
();
23
}
24
25
Mutex::native_handle_type
Mutex::native_handle
() {
26
return
nullptr
;
27
}
28
29
}
// namespace yaclib::detail::fiber
yaclib::detail::fiber::FiberQueue::Wait
WaitStatus Wait(NoTimeoutTag)
Definition
queue.cpp:5
yaclib::detail::fiber::FiberQueue::NotifyOne
void NotifyOne()
Definition
queue.cpp:21
yaclib::detail::fiber::Mutex::native_handle
native_handle_type native_handle()
Definition
mutex.cpp:25
yaclib::detail::fiber::Mutex::unlock
void unlock() noexcept
Definition
mutex.cpp:20
yaclib::detail::fiber::Mutex::_queue
FiberQueue _queue
Definition
mutex.hpp:26
yaclib::detail::fiber::Mutex::try_lock
bool try_lock() noexcept
Definition
mutex.cpp:12
yaclib::detail::fiber::Mutex::native_handle_type
void * native_handle_type
Definition
mutex.hpp:21
yaclib::detail::fiber::Mutex::_occupied
bool _occupied
Definition
mutex.hpp:27
yaclib::detail::fiber::Mutex::lock
void lock()
Definition
mutex.cpp:5
mutex.hpp
yaclib::detail::fiber
Definition
atomic.hpp:7
yaclib::MakeContract
Contract< V, E > MakeContract()
Creates related future and promise.
Definition
contract.hpp:25
yaclib::detail::fiber::NoTimeoutTag
Definition
queue.hpp:12
src
fault
fiber
mutex.cpp
Generated by
1.9.8