2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-02 08:52:07 +00:00

release lock in unlock() earlier

This commit is contained in:
Oliver Kowalke
2013-03-13 19:29:55 +01:00
parent 8d94982366
commit dcfb7be88d

View File

@@ -55,11 +55,13 @@ mutex::lock()
{
// notifier for main-fiber
n = detail::scheduler::instance().notifier();
// store this fiber in order to be notified later
unique_lock< detail::spinlock > lk( splk_);
waiting_.push_back( n);
lk.unlock();
// wait until main-fiber gets notified
while ( ! n->is_ready() )
{
// run scheduler
@@ -92,6 +94,7 @@ mutex::unlock()
n.swap( waiting_.front() );
waiting_.pop_front();
}
lk.unlock();
state_ = UNLOCKED;