2
0
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:
Oliver Kowalke
2013-08-16 21:24:32 +02:00
parent 94482d25b6
commit 4121cac318
20 changed files with 1451 additions and 260 deletions

View File

@@ -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();