mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-17 13:42:21 +00:00
support sleep_for()/sleep_until()
This commit is contained in:
@@ -59,6 +59,7 @@ context::context( main_context_t) :
|
||||
ready_hook_(),
|
||||
terminated_hook_(),
|
||||
wait_hook_(),
|
||||
tp_( (std::chrono::steady_clock::time_point::max)() ),
|
||||
use_count_( 1), // allocated on main- or thread-stack
|
||||
flags_( flag_main_context),
|
||||
scheduler_( nullptr),
|
||||
@@ -72,6 +73,7 @@ context::context( dispatcher_context_t, boost::context::preallocated const& pall
|
||||
ready_hook_(),
|
||||
terminated_hook_(),
|
||||
wait_hook_(),
|
||||
tp_( (std::chrono::steady_clock::time_point::max)() ),
|
||||
use_count_( 0), // scheduler will own dispatcher context
|
||||
flags_( flag_dispatcher_context),
|
||||
scheduler_( nullptr),
|
||||
@@ -151,6 +153,14 @@ context::yield() noexcept {
|
||||
scheduler_->yield( active_ctx);
|
||||
}
|
||||
|
||||
bool
|
||||
context::wait_until( std::chrono::steady_clock::time_point const& tp) {
|
||||
BOOST_ASSERT( nullptr != scheduler_);
|
||||
BOOST_ASSERT( this == active_);
|
||||
|
||||
return scheduler_->wait_until( this, tp);
|
||||
}
|
||||
|
||||
bool
|
||||
context::wait_is_linked() {
|
||||
return wait_hook_.is_linked();
|
||||
@@ -161,6 +171,11 @@ context::ready_is_linked() {
|
||||
return ready_hook_.is_linked();
|
||||
}
|
||||
|
||||
bool
|
||||
context::sleep_is_linked() {
|
||||
return sleep_hook_.is_linked();
|
||||
}
|
||||
|
||||
void
|
||||
context::wait_unlink() {
|
||||
wait_hook_.unlink();
|
||||
|
||||
Reference in New Issue
Block a user