Lighter version of Mutex with not more than 1 waiting task. More...
#include <userver/engine/single_waiting_task_mutex.hpp>
Public Member Functions | |
SingleWaitingTaskMutex (const SingleWaitingTaskMutex &)=delete | |
SingleWaitingTaskMutex (SingleWaitingTaskMutex &&)=delete | |
SingleWaitingTaskMutex & | operator= (const SingleWaitingTaskMutex &)=delete |
SingleWaitingTaskMutex & | operator= (SingleWaitingTaskMutex &&)=delete |
void | lock () |
void | unlock () |
bool | try_lock () |
template<typename Rep , typename Period > | |
bool | try_lock_for (const std::chrono::duration< Rep, Period > &) |
template<typename Clock , typename Duration > | |
bool | try_lock_until (const std::chrono::time_point< Clock, Duration > &) |
bool | try_lock_until (Deadline deadline) |
Lighter version of Mutex with not more than 1 waiting task.
There are some situations when a resource is accessed concurrently, but concurrency factor is limited by 2. For instance: implications of socket r/w duality
The class's API is the same as of engine::Mutex:
Definition at line 32 of file single_waiting_task_mutex.hpp.
void engine::SingleWaitingTaskMutex::lock | ( | ) |
Locks the mutex. Blocks current coroutine if the mutex is locked by another coroutine.
bool engine::SingleWaitingTaskMutex::try_lock_for | ( | const std::chrono::duration< Rep, Period > & | duration | ) |
Definition at line 72 of file single_waiting_task_mutex.hpp.
bool engine::SingleWaitingTaskMutex::try_lock_until | ( | const std::chrono::time_point< Clock, Duration > & | until | ) |
Definition at line 78 of file single_waiting_task_mutex.hpp.
void engine::SingleWaitingTaskMutex::unlock | ( | ) |
Unlocks the mutex. The mutex must be locked by the current coroutine.