From f18136562f39fac464d2a6d669b90c330143b2e1 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Wed, 9 Jan 2013 17:09:16 +0100 Subject: [PATCH] spin_mutext -> soinlock; fixes --- build/Jamfile.v2 | 2 +- include/boost/fiber/algorithm.hpp | 5 +- include/boost/fiber/condition.hpp | 30 +++-- include/boost/fiber/detail/fiber_base.hpp | 4 +- include/boost/fiber/detail/queue.hpp | 16 +-- .../detail/{spin_mutex.hpp => spinlock.hpp} | 22 +--- include/boost/fiber/future.hpp | 12 +- include/boost/fiber/mutex.hpp | 6 +- include/boost/fiber/round_robin.hpp | 5 +- src/condition.cpp | 8 +- src/detail/fiber_base.cpp | 3 +- src/detail/spin_mutex.cpp | 64 ----------- src/detail/spinlock.cpp | 37 ++++++ src/mutex.cpp | 29 +++-- src/round_robin.cpp | 2 +- test/Jamfile.v2 | 2 +- test/test_condition.cpp | 2 +- test/test_futures.cpp | 106 +++++++++--------- test/test_generic_locks.cpp | 20 ++-- test/test_lock.cpp | 22 ++-- test/test_unique_lock.cpp | 22 ++-- 21 files changed, 192 insertions(+), 227 deletions(-) rename include/boost/fiber/detail/{spin_mutex.hpp => spinlock.hpp} (51%) delete mode 100644 src/detail/spin_mutex.cpp create mode 100644 src/detail/spinlock.cpp diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 09464182..bb37d4ad 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -25,7 +25,7 @@ lib boost_fibers condition.cpp detail/fiber_base.cpp detail/scheduler.cpp - detail/spin_mutex.cpp + detail/spinlock.cpp fiber.cpp mutex.cpp round_robin.cpp diff --git a/include/boost/fiber/algorithm.hpp b/include/boost/fiber/algorithm.hpp index 1eb7cca6..e21baf9e 100644 --- a/include/boost/fiber/algorithm.hpp +++ b/include/boost/fiber/algorithm.hpp @@ -8,10 +8,11 @@ #include #include +#include #include #include -#include +#include #include #ifdef BOOST_HAS_ABI_HEADERS @@ -40,7 +41,7 @@ struct BOOST_FIBERS_DECL algorithm : private noncopyable virtual bool run() = 0; - virtual void wait( detail::spin_mutex::scoped_lock &) = 0; + virtual void wait( unique_lock< detail::spinlock > &) = 0; virtual void yield() = 0; diff --git a/include/boost/fiber/condition.hpp b/include/boost/fiber/condition.hpp index e83337ae..98a69705 100644 --- a/include/boost/fiber/condition.hpp +++ b/include/boost/fiber/condition.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -53,7 +53,7 @@ private: atomic< std::size_t > waiters_; mutex enter_mtx_; mutex check_mtx_; - detail::spin_mutex waiting_mtx_; + detail::spinlock waiting_mtx_; std::deque< detail::fiber_base::ptr_t > waiting_; public: @@ -75,8 +75,6 @@ public: template< typename LockType > void wait( LockType & lt) { - BOOST_ASSERT( this_fiber::is_fiberized() ); - { mutex::scoped_lock lk( enter_mtx_); BOOST_ASSERT( lk); @@ -93,10 +91,17 @@ public: //Notification occurred, we will lock the checking mutex so that while ( SLEEPING == cmd_) { - detail::spin_mutex::scoped_lock lk( waiting_mtx_); - waiting_.push_back( - detail::scheduler::instance().active() ); - detail::scheduler::instance().wait( lk); + if ( this_fiber::is_fiberized() ) + { + unique_lock< detail::spinlock > lk( waiting_mtx_); + waiting_.push_back( + detail::scheduler::instance().active() ); + detail::scheduler::instance().wait( lk); + } + else + { + run(); + } } command expected = NOTIFY_ONE; @@ -160,8 +165,6 @@ public: template< typename LockType > bool timed_wait( LockType & lt, chrono::system_clock::time_point const& abs_time) { - BOOST_ASSERT( this_fiber::is_fiberized() ); - if ( (chrono::system_clock::time_point::max)() == abs_time){ wait( lt); return true; @@ -186,12 +189,15 @@ public: while ( SLEEPING == cmd_) { #if 0 - detail::spin_mutex::scoped_lock lk( waiting_mtx_); + unique_lock< detail::spinlock > lk( waiting_mtx_); waiting_.push_back( detail::scheduler::instance().active() ); detail::scheduler::instance().wait( lk); #endif - this_fiber::yield(); + if ( this_fiber::is_fiberized() ) + this_fiber::yield(); + else + run(); now = chrono::system_clock::now(); if ( now >= abs_time) diff --git a/include/boost/fiber/detail/fiber_base.hpp b/include/boost/fiber/detail/fiber_base.hpp index 9451b8fb..2977b029 100644 --- a/include/boost/fiber/detail/fiber_base.hpp +++ b/include/boost/fiber/detail/fiber_base.hpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #ifdef BOOST_HAS_ABI_HEADERS @@ -50,7 +50,7 @@ private: context::fcontext_t * callee_; int flags_; exception_ptr except_; - spin_mutex mtx_; + spinlock mtx_; std::vector< ptr_t > joining_; protected: diff --git a/include/boost/fiber/detail/queue.hpp b/include/boost/fiber/detail/queue.hpp index 34b5058e..ae9e70ee 100644 --- a/include/boost/fiber/detail/queue.hpp +++ b/include/boost/fiber/detail/queue.hpp @@ -16,7 +16,7 @@ #include #include -#include +#include #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -53,16 +53,16 @@ class queue : private noncopyable { private: node::ptr_t head_; - mutable spin_mutex head_mtx_; + mutable spinlock head_mtx_; node::ptr_t tail_; - mutable spin_mutex tail_mtx_; + mutable spinlock tail_mtx_; bool empty_() const { return head_ == get_tail_(); } node_type::ptr get_tail_() const { - spin_mutex::scoped_lock lk( tail_mtx_); + spinlock::scoped_lock lk( tail_mtx_); node::ptr_t tmp = tail_; return tmp; } @@ -84,7 +84,7 @@ public: bool empty() const { - spin_mutex::scoped_lock lk( head_mtx_); + spinlock::scoped_lock lk( head_mtx_); return empty_(); } @@ -92,7 +92,7 @@ public: { node::ptr_t new_node( new node_type() ); { - spin_mutex::scoped_lock lk( tail_mtx_); + spinlock::scoped_lock lk( tail_mtx_); tail_->f = f; tail_->next = new_node; tail_ = new_node; @@ -101,7 +101,7 @@ public: void notify_one() { - spin_mutex::scoped_lock lk( head_mtx_); + spinlock::scoped_lock lk( head_mtx_); while ( ! empty_() ) { BOOST_ASSERT( head_->f); @@ -113,7 +113,7 @@ public: void notify_all() { - spin_mutex::scoped_lock lk( head_mtx_); + spinlock::scoped_lock lk( head_mtx_); while ( ! empty_() ) { BOOST_ASSERT( head_->f); diff --git a/include/boost/fiber/detail/spin_mutex.hpp b/include/boost/fiber/detail/spinlock.hpp similarity index 51% rename from include/boost/fiber/detail/spin_mutex.hpp rename to include/boost/fiber/detail/spinlock.hpp index 48ae8d99..a68d3023 100644 --- a/include/boost/fiber/detail/spin_mutex.hpp +++ b/include/boost/fiber/detail/spinlock.hpp @@ -6,12 +6,10 @@ // // based on boost::interprocess::sync::interprocess_spin::mutex -#ifndef BOOST_FIBERS_SPIN_MUTEX_H -#define BOOST_FIBERS_SPIN_MUTEX_H +#ifndef BOOST_FIBERS_SPINLOCK_H +#define BOOST_FIBERS_SPINLOCK_H #include -#include -#include #include #include @@ -20,7 +18,7 @@ namespace boost { namespace fibers { namespace detail { -class BOOST_FIBERS_DECL spin_mutex : private noncopyable +class BOOST_FIBERS_DECL spinlock : private noncopyable { private: enum state @@ -32,23 +30,13 @@ private: atomic< state > state_; public: - typedef unique_lock< spin_mutex > scoped_lock; - - spin_mutex(); + spinlock(); void lock(); - bool try_lock(); - - bool timed_lock( chrono::system_clock::time_point const& abs_time); - - template< typename TimeDuration > - bool timed_lock( TimeDuration const& rel_time) - { return timed_lock( chrono::system_clock::now() + rel_time); } - void unlock(); }; }}} -#endif // BOOST_FIBERS_SPIN_MUTEX_H +#endif // BOOST_FIBERS_SPINLOCK_H diff --git a/include/boost/fiber/future.hpp b/include/boost/fiber/future.hpp index 0c06508b..d398d6d3 100644 --- a/include/boost/fiber/future.hpp +++ b/include/boost/fiber/future.hpp @@ -140,7 +140,7 @@ namespace fibers { void remove_external_waiter(waiter_list::iterator it) { - boost::lock_guard lock(mutex); + boost::unique_lock lock(mutex); external_waiters.erase(it); } @@ -256,12 +256,12 @@ namespace fibers { bool has_value() { - boost::lock_guard lock(mutex); + boost::unique_lock lock(mutex); return done && !exception; } bool has_exception() { - boost::lock_guard lock(mutex); + boost::unique_lock lock(mutex); return done && exception; } @@ -390,7 +390,7 @@ namespace fibers { future_state::state get_state() { - boost::lock_guard guard(mutex); + boost::unique_lock guard(mutex); if(!done) { return future_state::waiting; @@ -431,7 +431,7 @@ namespace fibers { future_state::state get_state() { - boost::lock_guard guard(mutex); + boost::unique_lock guard(mutex); if(!done) { return future_state::waiting; @@ -1185,7 +1185,7 @@ namespace fibers { void run() { { - boost::lock_guard lk(this->mutex); + boost::unique_lock lk(this->mutex); if(started) { boost::throw_exception(task_already_started()); diff --git a/include/boost/fiber/mutex.hpp b/include/boost/fiber/mutex.hpp index a2dfab89..52f942ab 100644 --- a/include/boost/fiber/mutex.hpp +++ b/include/boost/fiber/mutex.hpp @@ -4,7 +4,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -// based on boost::interprocess::sync::interprocess_spin_mutex +// based on boost::interprocess::sync::interprocess_spinlock #ifndef BOOST_FIBERS_MUTEX_H #define BOOST_FIBERS_MUTEX_H @@ -18,7 +18,7 @@ #include #include -#include +#include #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -42,7 +42,7 @@ private: }; atomic< state > state_; - detail::spin_mutex mtx_; + detail::spinlock waiting_mtx_; std::deque< detail::fiber_base::ptr_t > waiting_; diff --git a/include/boost/fiber/round_robin.hpp b/include/boost/fiber/round_robin.hpp index f551bb25..5b23a98e 100644 --- a/include/boost/fiber/round_robin.hpp +++ b/include/boost/fiber/round_robin.hpp @@ -12,10 +12,11 @@ #include #include +#include #include #include -#include +#include #include #include @@ -59,7 +60,7 @@ public: bool run(); - void wait( detail::spin_mutex::scoped_lock &); + void wait( unique_lock< detail::spinlock > &); void yield(); diff --git a/src/condition.cpp b/src/condition.cpp index 8c9c2596..ad175236 100644 --- a/src/condition.cpp +++ b/src/condition.cpp @@ -34,8 +34,6 @@ condition::~condition() void condition::notify_one() { - BOOST_ASSERT( this_fiber::is_fiberized() ); - enter_mtx_.lock(); if ( 0 == waiters_) @@ -51,7 +49,7 @@ condition::notify_one() expected = SLEEPING; } - detail::spin_mutex::scoped_lock lk( waiting_mtx_); + unique_lock< detail::spinlock > lk( waiting_mtx_); if ( ! waiting_.empty() ) { detail::fiber_base::ptr_t f; @@ -64,8 +62,6 @@ condition::notify_one() void condition::notify_all() { - BOOST_ASSERT( this_fiber::is_fiberized() ); - //This mutex guarantees that no other thread can enter to the //do_timed_wait method logic, so that thread count will be //constant until the function writes a NOTIFY_ALL command. @@ -88,7 +84,7 @@ condition::notify_all() expected = SLEEPING; } - detail::spin_mutex::scoped_lock lk( waiting_mtx_); + unique_lock< detail::spinlock > lk( waiting_mtx_); BOOST_FOREACH( detail::fiber_base::ptr_t const& f, waiting_) { f->set_ready(); } waiting_.clear(); diff --git a/src/detail/fiber_base.cpp b/src/detail/fiber_base.cpp index f0ffa491..2f9c5933 100644 --- a/src/detail/fiber_base.cpp +++ b/src/detail/fiber_base.cpp @@ -9,6 +9,7 @@ #include #include +#include #include @@ -84,7 +85,7 @@ void fiber_base::join( ptr_t const& p) { // protect against concurrent access to joining_ - spin_mutex::scoped_lock lk( mtx_); + unique_lock< spinlock > lk( mtx_); if ( is_terminated() ) return; joining_.push_back( p); } diff --git a/src/detail/spin_mutex.cpp b/src/detail/spin_mutex.cpp deleted file mode 100644 index b14ea2c5..00000000 --- a/src/detail/spin_mutex.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_FIBERS_SOURCE - -#include - -#include -#include - -namespace boost { -namespace fibers { -namespace detail { - -spin_mutex::spin_mutex() : - state_( UNLOCKED) -{} - -void -spin_mutex::lock() -{ - while ( LOCKED == state_.exchange( LOCKED, memory_order_acquire) ) - { - // busy-wait - BOOST_ASSERT( this_fiber::is_fiberized() ); - this_fiber::yield(); - } -} - -bool -spin_mutex::timed_lock( chrono::system_clock::time_point const& abs_time) -{ - if ( chrono::system_clock::now() >= abs_time) - return false; - - for (;;) - { - if ( try_lock() ) break; - - if ( chrono::system_clock::now() >= abs_time) - return false; - - //this_fiber::interruption_point(); - //FIXME: what to do if not a fiber - BOOST_ASSERT( this_fiber::is_fiberized() ); - this_fiber::yield(); - //this_fiber::interruption_point(); - } - - return true; -} - -bool -spin_mutex::try_lock() -{ return UNLOCKED == state_.exchange( LOCKED, memory_order_acquire); } - -void -spin_mutex::unlock() -{ state_ = UNLOCKED; } - -}}} diff --git a/src/detail/spinlock.cpp b/src/detail/spinlock.cpp new file mode 100644 index 00000000..76f8cdcb --- /dev/null +++ b/src/detail/spinlock.cpp @@ -0,0 +1,37 @@ + +// Copyright Oliver Kowalke 2009. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#define BOOST_FIBERS_SOURCE + +#include + +#include +#include + +namespace boost { +namespace fibers { +namespace detail { + +spinlock::spinlock() : + state_( UNLOCKED) +{} + +void +spinlock::lock() +{ + while ( LOCKED == state_.exchange( LOCKED, memory_order_acquire) ) + { + // busy-wait + BOOST_ASSERT( this_fiber::is_fiberized() ); + this_fiber::yield(); + } +} + +void +spinlock::unlock() +{ state_ = UNLOCKED; } + +}}} diff --git a/src/mutex.cpp b/src/mutex.cpp index 3acb1c9b..4121fd85 100644 --- a/src/mutex.cpp +++ b/src/mutex.cpp @@ -22,40 +22,39 @@ namespace fibers { mutex::mutex() : state_( UNLOCKED), - mtx_(), + waiting_mtx_(), waiting_() {} void mutex::lock() { - BOOST_ASSERT( this_fiber::is_fiberized() ); - while ( LOCKED == state_.exchange( LOCKED, memory_order_acquire) ) { - detail::spin_mutex::scoped_lock lk( mtx_); - waiting_.push_back( - detail::scheduler::instance().active() ); - detail::scheduler::instance().wait( lk); + if ( this_fiber::is_fiberized() ) + { + unique_lock< detail::spinlock > lk( waiting_mtx_); + waiting_.push_back( + detail::scheduler::instance().active() ); + detail::scheduler::instance().wait( lk); + } + else + { + run(); + } } } bool mutex::try_lock() -{ - BOOST_ASSERT( this_fiber::is_fiberized() ); - - return UNLOCKED == state_.exchange( LOCKED, memory_order_acquire); -} +{ return UNLOCKED == state_.exchange( LOCKED, memory_order_acquire); } void mutex::unlock() { - BOOST_ASSERT( this_fiber::is_fiberized() ); - state_ = UNLOCKED; - detail::spin_mutex::scoped_lock lk( mtx_); + unique_lock< detail::spinlock > lk( waiting_mtx_); if ( ! waiting_.empty() ) { detail::fiber_base::ptr_t f; diff --git a/src/round_robin.cpp b/src/round_robin.cpp index d3971ff2..71f5bfe3 100644 --- a/src/round_robin.cpp +++ b/src/round_robin.cpp @@ -178,7 +178,7 @@ round_robin::run() } void -round_robin::wait( detail::spin_mutex::scoped_lock & lk) +round_robin::wait( unique_lock< detail::spinlock > & lk) { BOOST_ASSERT( active_fiber_); BOOST_ASSERT( active_fiber_->is_running() ); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 161aa2eb..77b6bf8d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -31,5 +31,5 @@ test-suite fibers : [ fiber-test test_lock ] [ fiber-test test_barrier ] [ fiber-test test_futures ] -# [ fiber-test test_then ] + [ fiber-test test_then ] ; diff --git a/test/test_condition.cpp b/test/test_condition.cpp index 8434b154..11c06e25 100644 --- a/test/test_condition.cpp +++ b/test/test_condition.cpp @@ -314,7 +314,7 @@ void test_condition_waits() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( do_test_condition_waits).join(); + do_test_condition_waits(); } boost::unit_test::test_suite * init_unit_test_suite( int, char* []) diff --git a/test/test_futures.cpp b/test/test_futures.cpp index 5b9a42cc..dbbafa2b 100644 --- a/test/test_futures.cpp +++ b/test/test_futures.cpp @@ -1159,7 +1159,7 @@ void test_store_value_from_thread() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( store_value_from_thread).join(); + store_value_from_thread(); } void test_store_exception() @@ -1167,7 +1167,7 @@ void test_store_exception() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( store_exception).join(); + store_exception(); } void test_initial_state() @@ -1175,7 +1175,7 @@ void test_initial_state() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( initial_state).join(); + initial_state(); } void test_waiting_future() @@ -1183,7 +1183,7 @@ void test_waiting_future() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( waiting_future).join(); + waiting_future(); } void test_cannot_get_future_twice() @@ -1191,7 +1191,7 @@ void test_cannot_get_future_twice() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( cannot_get_future_twice).join(); + cannot_get_future_twice(); } void test_set_value_updates_future_state() @@ -1199,7 +1199,7 @@ void test_set_value_updates_future_state() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( set_value_updates_future_state).join(); + set_value_updates_future_state(); } void test_set_value_can_be_retrieved() @@ -1207,7 +1207,7 @@ void test_set_value_can_be_retrieved() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( set_value_can_be_retrieved).join(); + set_value_can_be_retrieved(); } void test_set_value_can_be_moved() @@ -1219,7 +1219,7 @@ void test_future_from_packaged_task_is_waiting() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( future_from_packaged_task_is_waiting).join(); + future_from_packaged_task_is_waiting(); } void test_invoking_a_packaged_task_populates_future() @@ -1227,7 +1227,7 @@ void test_invoking_a_packaged_task_populates_future() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( invoking_a_packaged_task_populates_future).join(); + invoking_a_packaged_task_populates_future(); } void test_invoking_a_packaged_task_twice_throws() @@ -1235,7 +1235,7 @@ void test_invoking_a_packaged_task_twice_throws() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( invoking_a_packaged_task_twice_throws).join(); + invoking_a_packaged_task_twice_throws(); } void test_cannot_get_future_twice_from_task() @@ -1243,7 +1243,7 @@ void test_cannot_get_future_twice_from_task() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( cannot_get_future_twice_from_task).join(); + cannot_get_future_twice_from_task(); } void test_task_stores_exception_if_function_throws() @@ -1251,7 +1251,7 @@ void test_task_stores_exception_if_function_throws() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( task_stores_exception_if_function_throws).join(); + task_stores_exception_if_function_throws(); } void test_void_promise() @@ -1259,7 +1259,7 @@ void test_void_promise() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( void_promise).join(); + void_promise(); } void test_reference_promise() @@ -1267,7 +1267,7 @@ void test_reference_promise() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( reference_promise).join(); + reference_promise(); } void test_task_returning_void() @@ -1275,7 +1275,7 @@ void test_task_returning_void() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( task_returning_void).join(); + task_returning_void(); } void test_task_returning_reference() @@ -1283,7 +1283,7 @@ void test_task_returning_reference() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( task_returning_reference).join(); + task_returning_reference(); } void test_shared_future() @@ -1291,7 +1291,7 @@ void test_shared_future() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( shared_future).join(); + shared_future(); } void test_copies_of_shared_future_become_ready_together() @@ -1299,7 +1299,7 @@ void test_copies_of_shared_future_become_ready_together() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( copies_of_shared_future_become_ready_together).join(); + copies_of_shared_future_become_ready_together(); } void test_shared_future_can_be_move_assigned_from_unique_future() @@ -1307,7 +1307,7 @@ void test_shared_future_can_be_move_assigned_from_unique_future() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( shared_future_can_be_move_assigned_from_unique_future).join(); + shared_future_can_be_move_assigned_from_unique_future(); } void test_shared_future_void() @@ -1315,7 +1315,7 @@ void test_shared_future_void() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( shared_future_void).join(); + shared_future_void(); } void test_shared_future_ref() @@ -1323,7 +1323,7 @@ void test_shared_future_ref() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( shared_future_ref).join(); + shared_future_ref(); } void test_can_get_a_second_future_from_a_moved_promise() @@ -1331,7 +1331,7 @@ void test_can_get_a_second_future_from_a_moved_promise() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( can_get_a_second_future_from_a_moved_promise).join(); + can_get_a_second_future_from_a_moved_promise(); } void test_can_get_a_second_future_from_a_moved_void_promise() @@ -1339,7 +1339,7 @@ void test_can_get_a_second_future_from_a_moved_void_promise() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( can_get_a_second_future_from_a_moved_void_promise).join(); + can_get_a_second_future_from_a_moved_void_promise(); } #if 0 void test_unique_future_for_move_only_udt() @@ -1347,7 +1347,7 @@ void test_unique_future_for_move_only_udt() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( unique_future_for_move_only_udt).join(); + unique_future_for_move_only_udt(); } #endif void test_unique_future_for_string() @@ -1355,7 +1355,7 @@ void test_unique_future_for_string() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( unique_future_for_string).join(); + unique_future_for_string(); } void test_wait_callback() @@ -1363,7 +1363,7 @@ void test_wait_callback() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_callback).join(); + wait_callback(); } void test_wait_callback_with_timed_wait() @@ -1371,7 +1371,7 @@ void test_wait_callback_with_timed_wait() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_callback_with_timed_wait).join(); + wait_callback_with_timed_wait(); } void test_wait_callback_for_packaged_task() @@ -1379,7 +1379,7 @@ void test_wait_callback_for_packaged_task() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_callback_for_packaged_task).join(); + wait_callback_for_packaged_task(); } void test_packaged_task_can_be_moved() @@ -1387,7 +1387,7 @@ void test_packaged_task_can_be_moved() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( packaged_task_can_be_moved).join(); + packaged_task_can_be_moved(); } void test_destroying_a_promise_stores_broken_promise() @@ -1395,7 +1395,7 @@ void test_destroying_a_promise_stores_broken_promise() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( destroying_a_promise_stores_broken_promise).join(); + destroying_a_promise_stores_broken_promise(); } void test_destroying_a_packaged_task_stores_broken_promise() @@ -1403,7 +1403,7 @@ void test_destroying_a_packaged_task_stores_broken_promise() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( destroying_a_packaged_task_stores_broken_promise).join(); + destroying_a_packaged_task_stores_broken_promise(); } void test_wait_for_either_of_two_futures_1() @@ -1411,7 +1411,7 @@ void test_wait_for_either_of_two_futures_1() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_two_futures_1).join(); + wait_for_either_of_two_futures_1(); } void test_wait_for_either_of_two_futures_2() @@ -1419,7 +1419,7 @@ void test_wait_for_either_of_two_futures_2() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_two_futures_2).join(); + wait_for_either_of_two_futures_2(); } void test_wait_for_either_of_three_futures_1() @@ -1427,7 +1427,7 @@ void test_wait_for_either_of_three_futures_1() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_three_futures_1).join(); + wait_for_either_of_three_futures_1(); } void test_wait_for_either_of_three_futures_2() @@ -1435,7 +1435,7 @@ void test_wait_for_either_of_three_futures_2() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_three_futures_2).join(); + wait_for_either_of_three_futures_2(); } void test_wait_for_either_of_three_futures_3() @@ -1443,7 +1443,7 @@ void test_wait_for_either_of_three_futures_3() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_three_futures_3).join(); + wait_for_either_of_three_futures_3(); } void test_wait_for_either_of_four_futures_1() @@ -1451,7 +1451,7 @@ void test_wait_for_either_of_four_futures_1() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_four_futures_1).join(); + wait_for_either_of_four_futures_1(); } void test_wait_for_either_of_four_futures_2() @@ -1459,7 +1459,7 @@ void test_wait_for_either_of_four_futures_2() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_four_futures_2).join(); + wait_for_either_of_four_futures_2(); } void test_wait_for_either_of_four_futures_3() @@ -1467,7 +1467,7 @@ void test_wait_for_either_of_four_futures_3() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_four_futures_3).join(); + wait_for_either_of_four_futures_3(); } void test_wait_for_either_of_four_futures_4() @@ -1475,7 +1475,7 @@ void test_wait_for_either_of_four_futures_4() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_four_futures_4).join(); + wait_for_either_of_four_futures_4(); } void test_wait_for_either_of_five_futures_1() @@ -1483,7 +1483,7 @@ void test_wait_for_either_of_five_futures_1() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_five_futures_1).join(); + wait_for_either_of_five_futures_1(); } void test_wait_for_either_of_five_futures_2() @@ -1491,7 +1491,7 @@ void test_wait_for_either_of_five_futures_2() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_five_futures_2).join(); + wait_for_either_of_five_futures_2(); } void test_wait_for_either_of_five_futures_3() @@ -1499,7 +1499,7 @@ void test_wait_for_either_of_five_futures_3() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_five_futures_3).join(); + wait_for_either_of_five_futures_3(); } void test_wait_for_either_of_five_futures_4() @@ -1507,7 +1507,7 @@ void test_wait_for_either_of_five_futures_4() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_five_futures_4).join(); + wait_for_either_of_five_futures_4(); } void test_wait_for_either_of_five_futures_5() @@ -1515,7 +1515,7 @@ void test_wait_for_either_of_five_futures_5() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_of_five_futures_5).join(); + wait_for_either_of_five_futures_5(); } void test_wait_for_either_invokes_callbacks() @@ -1523,7 +1523,7 @@ void test_wait_for_either_invokes_callbacks() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_either_invokes_callbacks).join(); + wait_for_either_invokes_callbacks(); } #if 0 void test_wait_for_any_from_range() @@ -1531,7 +1531,7 @@ void test_wait_for_any_from_range() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_any_from_range).join(); + wait_for_any_from_range(); } void test_wait_for_all_from_range() @@ -1539,7 +1539,7 @@ void test_wait_for_all_from_range() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_all_from_range).join(); + wait_for_all_from_range(); } #endif void test_wait_for_all_two_futures() @@ -1547,7 +1547,7 @@ void test_wait_for_all_two_futures() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_all_two_futures).join(); + wait_for_all_two_futures(); } void test_wait_for_all_three_futures() @@ -1555,7 +1555,7 @@ void test_wait_for_all_three_futures() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_all_three_futures).join(); + wait_for_all_three_futures(); } void test_wait_for_all_four_futures() @@ -1563,7 +1563,7 @@ void test_wait_for_all_four_futures() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_all_four_futures).join(); + wait_for_all_four_futures(); } void test_wait_for_all_five_futures() @@ -1571,7 +1571,7 @@ void test_wait_for_all_five_futures() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( wait_for_all_five_futures).join(); + wait_for_all_five_futures(); } void test_future_wait() @@ -1579,7 +1579,7 @@ void test_future_wait() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( future_wait).join(); + future_wait(); } boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[]) diff --git a/test/test_generic_locks.cpp b/test/test_generic_locks.cpp index 49bf203d..5775a487 100644 --- a/test/test_generic_locks.cpp +++ b/test/test_generic_locks.cpp @@ -360,7 +360,7 @@ void test_lock_two_uncontended() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( lock_two_uncontended).join(); + lock_two_uncontended(); } void test_lock_five_uncontended() @@ -368,7 +368,7 @@ void test_lock_five_uncontended() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( lock_five_uncontended).join(); + lock_five_uncontended(); } void test_lock_five_in_range() @@ -376,7 +376,7 @@ void test_lock_five_in_range() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( lock_five_in_range).join(); + lock_five_in_range(); } void test_lock_ten_in_range() @@ -384,7 +384,7 @@ void test_lock_ten_in_range() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( lock_ten_in_range).join(); + lock_ten_in_range(); } void test_try_lock_two_uncontended() @@ -392,7 +392,7 @@ void test_try_lock_two_uncontended() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock_two_uncontended).join(); + try_lock_two_uncontended(); } void test_try_lock_two_first_locked() @@ -400,7 +400,7 @@ void test_try_lock_two_first_locked() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock_two_first_locked).join(); + try_lock_two_first_locked(); } void test_try_lock_two_second_locked() @@ -408,7 +408,7 @@ void test_try_lock_two_second_locked() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock_two_second_locked).join(); + try_lock_two_second_locked(); } void test_try_lock_three() @@ -416,7 +416,7 @@ void test_try_lock_three() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock_three).join(); + try_lock_three(); } void test_try_lock_four() @@ -424,7 +424,7 @@ void test_try_lock_four() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock_four).join(); + try_lock_four(); } void test_try_lock_five() @@ -432,7 +432,7 @@ void test_try_lock_five() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock_five).join(); + try_lock_five(); } boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[]) diff --git a/test/test_lock.cpp b/test/test_lock.cpp index a983bd02..8bc303db 100644 --- a/test/test_lock.cpp +++ b/test/test_lock.cpp @@ -184,7 +184,7 @@ void test_lock() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( lock).join(); + lock(); } void test_defer_lock() @@ -192,7 +192,7 @@ void test_defer_lock() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( defer_lock).join(); + defer_lock(); } void test_adopt_lock() @@ -200,7 +200,7 @@ void test_adopt_lock() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( adopt_lock).join(); + adopt_lock(); } void test_try_lock() @@ -208,7 +208,7 @@ void test_try_lock() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock).join(); + try_lock(); } void test_lock_twice() @@ -216,7 +216,7 @@ void test_lock_twice() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( lock_twice).join(); + lock_twice(); } void test_try_lock_twice() @@ -224,7 +224,7 @@ void test_try_lock_twice() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock_twice).join(); + try_lock_twice(); } void test_unlock_twice() @@ -232,7 +232,7 @@ void test_unlock_twice() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( unlock_twice).join(); + unlock_twice(); } void test_default_ctor() @@ -240,7 +240,7 @@ void test_default_ctor() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( default_ctor).join(); + default_ctor(); } void test_lock_concept() @@ -248,7 +248,7 @@ void test_lock_concept() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( lock_concept).join(); + lock_concept(); } void test_try_lock_concept() @@ -256,7 +256,7 @@ void test_try_lock_concept() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock_concept).join(); + try_lock_concept(); } void test_swap() @@ -264,7 +264,7 @@ void test_swap() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( swap).join(); + swap(); } boost::unit_test::test_suite * init_unit_test_suite( int, char* []) diff --git a/test/test_unique_lock.cpp b/test/test_unique_lock.cpp index c66414bd..87828ab8 100644 --- a/test/test_unique_lock.cpp +++ b/test/test_unique_lock.cpp @@ -184,7 +184,7 @@ void test_lock() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( lock).join(); + lock(); } void test_defer_lock() @@ -192,7 +192,7 @@ void test_defer_lock() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( defer_lock).join(); + defer_lock(); } void test_adopt_lock() @@ -200,7 +200,7 @@ void test_adopt_lock() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( adopt_lock).join(); + adopt_lock(); } void test_try_lock() @@ -208,7 +208,7 @@ void test_try_lock() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock).join(); + try_lock(); } void test_lock_twice() @@ -216,7 +216,7 @@ void test_lock_twice() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( lock_twice).join(); + lock_twice(); } void test_try_lock_twice() @@ -224,7 +224,7 @@ void test_try_lock_twice() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock_twice).join(); + try_lock_twice(); } void test_unlock_twice() @@ -232,7 +232,7 @@ void test_unlock_twice() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( unlock_twice).join(); + unlock_twice(); } void test_default_ctor() @@ -240,7 +240,7 @@ void test_default_ctor() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( default_ctor).join(); + default_ctor(); } void test_lock_concept() @@ -248,7 +248,7 @@ void test_lock_concept() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( lock_concept).join(); + lock_concept(); } void test_try_lock_concept() @@ -256,7 +256,7 @@ void test_try_lock_concept() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( try_lock_concept).join(); + try_lock_concept(); } void test_swap() @@ -264,7 +264,7 @@ void test_swap() boost::fibers::round_robin ds; boost::fibers::scheduling_algorithm( & ds); - boost::fibers::fiber( swap).join(); + swap(); } boost::unit_test::test_suite * init_unit_test_suite( int, char* [])