summaryrefslogtreecommitdiff
path: root/boost/fiber/operations.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/fiber/operations.hpp')
-rw-r--r--boost/fiber/operations.hpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/boost/fiber/operations.hpp b/boost/fiber/operations.hpp
index 95ab9ba452..22b58562da 100644
--- a/boost/fiber/operations.hpp
+++ b/boost/fiber/operations.hpp
@@ -10,6 +10,7 @@
#include <boost/config.hpp>
+#include <boost/fiber/algo/algorithm.hpp>
#include <boost/fiber/context.hpp>
#include <boost/fiber/detail/config.hpp>
#include <boost/fiber/detail/convert.hpp>
@@ -36,19 +37,22 @@ void yield() noexcept {
template< typename Clock, typename Duration >
void sleep_until( std::chrono::time_point< Clock, Duration > const& sleep_time_) {
std::chrono::steady_clock::time_point sleep_time = boost::fibers::detail::convert( sleep_time_);
- fibers::context::active()->wait_until( sleep_time);
+ fibers::context * active_ctx = fibers::context::active();
+ active_ctx->twstatus.store( static_cast< std::intptr_t >( 0), std::memory_order_release);
+ active_ctx->wait_until( sleep_time);
}
template< typename Rep, typename Period >
void sleep_for( std::chrono::duration< Rep, Period > const& timeout_duration) {
- fibers::context::active()->wait_until(
- std::chrono::steady_clock::now() + timeout_duration);
+ fibers::context * active_ctx = fibers::context::active();
+ active_ctx->twstatus.store( static_cast< std::intptr_t >( 0), std::memory_order_release);
+ active_ctx->wait_until( std::chrono::steady_clock::now() + timeout_duration);
}
template< typename PROPS >
PROPS & properties() {
fibers::fiber_properties * props = fibers::context::active()->get_properties();
- if ( ! props) {
+ if ( BOOST_LIKELY( nullptr == props) ) {
// props could be nullptr if the thread's main fiber has not yet
// yielded (not yet passed through algorithm_with_properties::
// awakened()). Address that by yielding right now.
@@ -76,9 +80,7 @@ bool has_ready_fibers() noexcept {
template< typename SchedAlgo, typename ... Args >
void use_scheduling_algorithm( Args && ... args) noexcept {
boost::fibers::context::active()->get_scheduler()
- ->set_algo(
- std::unique_ptr< SchedAlgo >(
- new SchedAlgo( std::forward< Args >( args) ... ) ) );
+ ->set_algo( new SchedAlgo( std::forward< Args >( args) ... ) );
}
}}