Beispiel #1
0
    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;
    }
Beispiel #2
0
 void interval_timer::slow_down(util::steady_duration const& max_interval)
 {
     return timer_->slow_down(max_interval.value().count() / 1000);
 }
Beispiel #3
0
 void interval_timer::speed_up(util::steady_duration const& min_interval)
 {
     return timer_->speed_up(min_interval.value().count() / 1000);
 }
Beispiel #4
0
 interval_timer::interval_timer(util::function_nonser<bool()> const& f,
         util::steady_duration const& rel_time,
         char const*  description, bool pre_shutdown)
   : timer_(std::make_shared<detail::interval_timer>(
         f, rel_time.value().count() / 1000, description, pre_shutdown))
 {}