2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-17 01:32:32 +00:00

signal() added

This commit is contained in:
Oliver Kowalke
2015-09-10 19:52:08 +02:00
parent d3843efbe0
commit 4764c1184c
10 changed files with 94 additions and 95 deletions

View File

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