mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-17 01:32:32 +00:00
signal() added
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
|
||||
#include "boost/fiber/scheduler.hpp"
|
||||
#include "boost/fiber/interruption.hpp"
|
||||
#include "boost/fiber/operations.hpp"
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
@@ -26,10 +25,10 @@ recursive_mutex::lock_if_unlocked_() {
|
||||
if ( mutex_status::unlocked == state_) {
|
||||
state_ = mutex_status::locked;
|
||||
BOOST_ASSERT( ! owner_);
|
||||
owner_ = this_fiber::get_id();
|
||||
owner_ = context::active()->get_id();
|
||||
++count_;
|
||||
return true;
|
||||
} else if ( this_fiber::get_id() == owner_) {
|
||||
} else if ( context::active()->get_id() == owner_) {
|
||||
++count_;
|
||||
return true;
|
||||
}
|
||||
@@ -64,10 +63,12 @@ recursive_mutex::lock() {
|
||||
|
||||
// store this fiber in order to be notified later
|
||||
BOOST_ASSERT( ! f->wait_is_linked() );
|
||||
f->set_waiting();
|
||||
wait_queue_.push_back( * f);
|
||||
lk.unlock();
|
||||
|
||||
// suspend this fiber
|
||||
context::active()->do_wait( lk);
|
||||
f->do_schedule();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,14 +83,14 @@ recursive_mutex::try_lock() {
|
||||
lk.unlock();
|
||||
|
||||
// let other fiber release the lock
|
||||
this_fiber::yield();
|
||||
context::active()->do_yield();
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
recursive_mutex::unlock() {
|
||||
BOOST_ASSERT( mutex_status::locked == state_);
|
||||
BOOST_ASSERT( this_fiber::get_id() == owner_);
|
||||
BOOST_ASSERT( context::active()->get_id() == owner_);
|
||||
|
||||
detail::spinlock_lock lk( splk_);
|
||||
context * f( nullptr);
|
||||
@@ -104,8 +105,7 @@ recursive_mutex::unlock() {
|
||||
lk.unlock();
|
||||
|
||||
if ( nullptr != f) {
|
||||
BOOST_ASSERT( ! f->is_terminated() );
|
||||
f->set_ready();
|
||||
context::active()->do_signal( f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user