7 #ifndef __MERCURY_COROUTINE_ENGINE_MUTEX__
8 #define __MERCURY_COROUTINE_ENGINE_MUTEX__
22 mutex() : acquired_{
false} { }
28 std::unique_lock<mce::spinlock> lk(lk_);
34 notify_q_.push_back(&p);
39 else { acquired_ =
true; }
45 std::unique_lock<mce::spinlock> lk(lk_);
51 notify_q_.front()->unpark(lk);
52 notify_q_.pop_front();
61 std::unique_lock<mce::spinlock> lk(lk_);
67 else {
return false; }
72 virtual const char* what()
const throw()
74 return "Cannot unlock an already unlocked mutex";
bool try_lock()
Attempt to the lock the mutex, returning true if successful, else false.
Definition: mutex.hpp:59
void unlock()
Unlock the mutex.
Definition: mutex.hpp:43
void lock()
Lock the mutex, blocking until lock is acquired.
Definition: mutex.hpp:26
object containing information to block and unblock a coroutine (running in a scheduler) or thread
Definition: scheduler.hpp:268
void park(LOCK &lk)
blocking call until unpark, unlocks and relocks given lock as necessary
Definition: scheduler.hpp:283
mce::detail::queue< parkable * > parkable_queue
most straightforward blocked queue
Definition: scheduler.hpp:428
Core mechanism for atomic synchronization.
Definition: atomic.hpp:20