mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-20 02:32:19 +00:00
some source code formating
This commit is contained in:
@@ -30,7 +30,6 @@ recursive_timed_mutex::lock_if_unlocked_() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( mutex_status::unlocked != state_.exchange( mutex_status::locked, std::memory_order_acquire) ) {
|
||||
if ( context::active() == owner_) {
|
||||
++count_;
|
||||
@@ -39,7 +38,6 @@ recursive_timed_mutex::lock_if_unlocked_() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_ASSERT( nullptr == owner_);
|
||||
owner_ = context::active();
|
||||
++count_;
|
||||
@@ -68,16 +66,13 @@ recursive_timed_mutex::lock() {
|
||||
if ( lock_if_unlocked_() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// store this fiber in order to be notified later
|
||||
detail::spinlock_lock lk( wait_queue_splk_);
|
||||
BOOST_ASSERT( ! ctx->wait_is_linked() );
|
||||
wait_queue_.push_back( * ctx);
|
||||
lk.unlock();
|
||||
|
||||
// suspend this fiber
|
||||
ctx->suspend();
|
||||
|
||||
// remove fiber from wait-queue
|
||||
lk.lock();
|
||||
ctx->wait_unlink();
|
||||
@@ -95,7 +90,6 @@ recursive_timed_mutex::try_lock() {
|
||||
if ( lock_if_unlocked_() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// let other fiber release the lock
|
||||
context::active()->yield();
|
||||
return false;
|
||||
@@ -109,17 +103,14 @@ recursive_timed_mutex::try_lock_until_( std::chrono::steady_clock::time_point co
|
||||
if ( std::chrono::steady_clock::now() > timeout_time) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( lock_if_unlocked_() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// store this fiber in order to be notified later
|
||||
detail::spinlock_lock lk( wait_queue_splk_);
|
||||
BOOST_ASSERT( ! ctx->wait_is_linked() );
|
||||
wait_queue_.push_back( * ctx);
|
||||
lk.unlock();
|
||||
|
||||
// suspend this fiber until notified or timed-out
|
||||
if ( ! ctx->wait_until( timeout_time) ) {
|
||||
// remove fiber from wait-queue
|
||||
@@ -127,7 +118,6 @@ recursive_timed_mutex::try_lock_until_( std::chrono::steady_clock::time_point co
|
||||
ctx->wait_unlink();
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove fiber from wait-queue
|
||||
lk.lock();
|
||||
ctx->wait_unlink();
|
||||
@@ -144,7 +134,6 @@ void
|
||||
recursive_timed_mutex::unlock() {
|
||||
BOOST_ASSERT( mutex_status::locked == state_);
|
||||
BOOST_ASSERT( context::active() == owner_);
|
||||
|
||||
detail::spinlock_lock lk( wait_queue_splk_);
|
||||
context * ctx( nullptr);
|
||||
if ( 0 == --count_) {
|
||||
@@ -156,7 +145,6 @@ recursive_timed_mutex::unlock() {
|
||||
lk.unlock();
|
||||
owner_ = nullptr;
|
||||
state_.store( mutex_status::unlocked, std::memory_order_release);
|
||||
|
||||
if ( nullptr != ctx) {
|
||||
context::active()->set_ready( ctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user