/// The function \a suspend will return control to the thread manager /// (suspends the current thread). It sets the new state of this thread /// to \a suspended and schedules a wakeup for this threads after the given /// duration. /// /// \note Must be called from within a HPX-thread. /// /// \throws If <code>&ec != &throws</code>, never throws, but will set \a ec /// to an appropriate value when an error occurs. Otherwise, this /// function will throw an \a hpx#exception with an error code of /// \a hpx#yield_aborted if it is signaled with \a wait_aborted. /// If called outside of a HPX-thread, this function will throw /// an \a hpx#exception with an error code of \a hpx::null_thread_id. /// If this function is called while the thread-manager is not /// running, it will throw an \a hpx#exception with an error code of /// \a hpx#invalid_status. /// inline threads::thread_state_ex_enum suspend( util::steady_duration const& rel_time, char const* description = "this_thread::suspend", error_code& ec = throws) { return suspend(rel_time.from_now(), description, ec); }
thread_id_type set_thread_state_timed(SchedulingPolicy& scheduler, util::steady_duration const& rel_time, thread_id_type const& thrd, error_code& ec) { return set_thread_state_timed(scheduler, rel_time.from_now(), thrd, pending, wait_timeout, thread_priority_normal, std::size_t(-1), ec); }
thread_id_type set_thread_state_timed(SchedulingPolicy& scheduler, util::steady_duration const& rel_time, thread_id_type const& thrd, thread_state_enum newstate, thread_state_ex_enum newstate_ex, thread_priority priority, std::size_t thread_num, error_code& ec) { return set_thread_state_timed(scheduler, rel_time.from_now(), thrd, newstate, newstate_ex, priority, thread_num, ec); }
interval_timer::interval_timer(util::function_nonser<bool()> const& f, util::function_nonser<void()> const& on_term, util::steady_duration const& rel_time, char const* description, bool pre_shutdown) : timer_(std::make_shared<detail::interval_timer>( f, on_term, rel_time.value().count() / 1000, description, pre_shutdown)) {}
/////////////////////////////////////////////////////////////////////////// /// \brief Set the thread state of the \a thread referenced by the /// thread_id \a id. /// /// Set a timer to set the state of the given \a thread to the given /// new value after it expired (after the given duration) /// /// \param id [in] The thread id of the thread the state should /// be modified for. /// \param after_duration /// \param state [in] The new state to be set for the thread /// referenced by the \a id parameter. /// \param state_ex [in] The new extended state to be set for the /// thread referenced by the \a id parameter. /// \param priority /// \param ec [in,out] this represents the error status on exit, /// if this is pre-initialized to \a hpx#throws /// the function will throw on error instead. /// /// \returns /// /// \note As long as \a ec is not pre-initialized to /// \a hpx#throws this function doesn't /// throw but returns the result code using the /// parameter \a ec. Otherwise it throws an instance /// of hpx#exception. inline thread_id_type set_thread_state(thread_id_type const& id, util::steady_duration const& rel_time, thread_state_enum state = pending, thread_state_ex_enum stateex = wait_timeout, thread_priority priority = thread_priority_normal, error_code& ec = throws) { return set_thread_state(id, rel_time.from_now(), state, stateex, priority, ec); }
bool pool_timer::start(util::steady_duration const& time_duration, bool evaluate_) { std::unique_lock<mutex_type> l(mtx_); if (is_terminated_) return false; if (!is_started_) { if (first_start_) { first_start_ = false; util::unlock_guard<std::unique_lock<mutex_type> > ul(l); if (pre_shutdown_) { register_pre_shutdown_function( util::bind(&pool_timer::terminate, this->shared_from_this())); } else { register_shutdown_function( util::bind(&pool_timer::terminate, this->shared_from_this())); } } is_stopped_ = false; is_started_ = true; HPX_ASSERT(timer_ != nullptr); timer_->expires_from_now(time_duration.value()); timer_->async_wait(util::bind(&pool_timer::timer_handler, this->shared_from_this(), util::placeholders::_1)); return true; } return false; }
bool try_lock_for(util::steady_duration const& rel_time, char const* description, error_code& ec = throws) { return try_lock_until(rel_time.from_now(), description, ec); }
cv_status wait_for(Lock& lock, util::steady_duration const& rel_time, error_code& ec = throws) { return wait_until(lock, rel_time.from_now(), ec); }
bool wait_for(Lock& lock, util::steady_duration const& rel_time, Predicate pred, error_code& ec = throws) { return wait_until(lock, rel_time.from_now(), std::move(pred), ec); }
void interval_timer::speed_up(util::steady_duration const& min_interval) { return timer_->speed_up(min_interval.value().count() / 1000); }
void interval_timer::slow_down(util::steady_duration const& max_interval) { return timer_->slow_down(max_interval.value().count() / 1000); }