mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-10 23:32:28 +00:00
add support for timed-operations (wait_for/wait_until)
This commit is contained in:
@@ -94,7 +94,20 @@ recursive_mutex::lock()
|
||||
bool
|
||||
recursive_mutex::try_lock()
|
||||
{
|
||||
if ( LOCKED == state_) return false;
|
||||
if ( LOCKED == state_)
|
||||
{
|
||||
if ( this_fiber::get_id() == owner_)
|
||||
{
|
||||
++count_;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// let other fiber release the lock
|
||||
detail::scheduler::instance()->yield();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
state_ = LOCKED;
|
||||
owner_ = this_fiber::get_id();
|
||||
|
||||
Reference in New Issue
Block a user