当前位置: 首页>>代码示例>>C++>>正文


C++ deadline_timer::expires_from_now方法代码示例

本文整理汇总了C++中boost::asio::deadline_timer::expires_from_now方法的典型用法代码示例。如果您正苦于以下问题:C++ deadline_timer::expires_from_now方法的具体用法?C++ deadline_timer::expires_from_now怎么用?C++ deadline_timer::expires_from_now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::asio::deadline_timer的用法示例。


在下文中一共展示了deadline_timer::expires_from_now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: timeout

	void timeout(const boost::system::error_code &e) {
		if(
		    mum!=nullptr &&
		    m_audiofifo!=nullptr &&
		    mum->getConnectionState()==mumlib::ConnectionState::CONNECTED &&
		    m_audiofifo->getNoOfFrames() >= output_frame_size
		) {
			timer.expires_from_now(boost::posix_time::milliseconds(60));
			auto packet=m_audiofifo->getAudio();
			mum->sendAudioData(packet->m_samples, output_frame_size, mumlib::SourceAudioPacketType::FLOAT);
			delete packet;
		} else {
			timer.expires_from_now(boost::posix_time::seconds(2));
		}
		timer.async_wait(timeout_handler);
	};
开发者ID:ysblokje,项目名称:mumble-jukebox,代码行数:16,代码来源:player.hpp

示例2: start

	void start(FIFO_TYPE *audiofifo) {
		m_audiofifo = audiofifo;
		if(running)
			return;
		timer.expires_from_now(boost::posix_time::seconds(2));
		timer.async_wait(timeout_handler);
	}
开发者ID:ysblokje,项目名称:mumble-jukebox,代码行数:7,代码来源:player.hpp

示例3: print

void print(const boost::system::error_code& e)
{
	std::cout << i++ << ": Hello, world!\n";
	std::cout << e << std::endl;
	t.expires_from_now(boost::posix_time::seconds(1));
	t.async_wait(print);
}
开发者ID:xtwxy,项目名称:boost-reciple,代码行数:7,代码来源:main.cpp

示例4: set_timer

inline void set_timer(io::deadline_timer& timer, uint64_t milliseconds,
                      Handler&& handler) {
  if (milliseconds != length_framed_connection::no_deadline) {
    timer.expires_from_now(boost::posix_time::milliseconds(milliseconds));
    timer.async_wait(std::forward<Handler>(handler));
  }
}
开发者ID:reinfer,项目名称:riakpp,代码行数:7,代码来源:length_framed_connection.cpp

示例5: on_check

void thread_pool_checker::on_check(const boost::system::error_code& error)
{
    // On error, return early.
    if (error)
        return;

    // Check how long this job was waiting in the service queue.  This
    // returns the expiration time relative to now.  Thus, if it expired
    // 7 seconds ago, then the delta time is -7 seconds.
    boost::posix_time::time_duration delta = timer_.expires_from_now();
    long wait_in_seconds = -delta.seconds();

    // If the time delta is greater than the threshold, then the job
    // remained in the service queue for too long, so increase the
    // thread pool.
    std::cout << "Job job sat in queue for " << wait_in_seconds << " seconds."
                << std::endl;
    if (threshold_seconds_ < wait_in_seconds)
    {
        std::cout << "Increasing thread pool." << std::endl;
        threads_.create_thread(
                    boost::bind(&boost::asio::io_service::run, &io_service_));
    }

    // Otherwise, schedule another pool check.
    run();
}
开发者ID:bonly,项目名称:exercise,代码行数:27,代码来源:20100528_io_pool.cpp

示例6: check_interrupt

		static void check_interrupt( boost::asio::deadline_timer& c )
		{
			if( boost::this_thread::interruption_requested() ) 
				throw std::runtime_error("Thread interrupted.");
			c.expires_from_now( boost::posix_time::seconds(1) );
			c.async_wait( boost::bind( &listener::check_interrupt, boost::ref(c) ) );
		}
开发者ID:jadedrip,项目名称:lugce,代码行数:7,代码来源:listener.hpp

示例7: Wait

 void Wait() {
     if (!queue_.empty()) {
         std::cout << "t0 + " << std::setw(4) << mark() << "ms Open for Number :   "  << type <<  " (dur:"  << queue_.front() <<  ") (depth " << queue_.size() << ")\n";
         timer_.expires_from_now(boost::posix_time::milliseconds(queue_.front()));
         timer_.async_wait(strand_.wrap(std::bind(&Session::Close, shared_from_this())));
     }
 }
开发者ID:CCJY,项目名称:coliru,代码行数:7,代码来源:main.cpp

示例8: handle_timer

//---------------------------------------------------------
void handle_timer(boost::asio::deadline_timer& timer, const boost::system::error_code& ec)
{
	std::cout<<"*"<<std::flush;

	timer.expires_from_now(boost::posix_time::seconds(1)); ///!\ important /!\ got to be reset
	timer.async_wait(boost::bind(handle_timer, boost::ref(timer), boost::asio::placeholders::error));
}
开发者ID:alexandry-augustin,项目名称:boost,代码行数:8,代码来源:boost_asio_timer.cpp

示例9: justdoit

 void justdoit()
 {
     rc_->get(strand_.wrap(
         boost::bind(&tormoz_get::handle_done, shared_from_this(), _1, _2))
              );
     timer_.expires_from_now(boost::posix_time::milliseconds(100));
     timer_.async_wait(strand_.wrap(boost::bind(&tormoz_get::handle_timeout, shared_from_this(), _1)));
 }
开发者ID:alexeimoisseev,项目名称:NwSMTP,代码行数:8,代码来源:tormoz2.cpp

示例10: on_open

 void on_open() override {
     auto self(shared_from_this());
     std::cout << "WebSocket connection open\n";
     timer_.expires_from_now(boost::posix_time::milliseconds(100));
     timer_.async_wait([this, self](const boost::system::error_code &ec) {
         timer_cb(ec);
     });
 }
开发者ID:alexyoung91,项目名称:ws,代码行数:8,代码来源:timed_server.cpp

示例11: do_timer

  void do_timer(const boost::system::error_code&)
  {
    callback();

    // reset the timer
    timer.expires_from_now(checkpoint_interval);
    timer.async_wait(boost::bind(&handlers::do_timer, this, _1));
  }
开发者ID:andreabedini,项目名称:isaw-sq-flatperm,代码行数:8,代码来源:main.cpp

示例12: reconnect

 void reconnect() {
     if (m_abort || m_reconnect_secs <= 0)
         return;
     m_reconnect_timer.expires_from_now(boost::posix_time::seconds(m_reconnect_secs));
     m_reconnect_timer.async_wait(
         boost::bind(&self::timer_reconnect, this->shared_from_this(),
                     boost::asio::placeholders::error));
 }
开发者ID:alepharchives,项目名称:eixx,代码行数:8,代码来源:basic_otp_connection.hpp

示例13: keepRunning

void PionScheduler::keepRunning(boost::asio::io_service& my_service,
								boost::asio::deadline_timer& my_timer)
{
	if (m_is_running) {
		// schedule this again to make sure the service doesn't complete
		my_timer.expires_from_now(boost::posix_time::seconds(KEEP_RUNNING_TIMER_SECONDS));
		my_timer.async_wait(boost::bind(&PionScheduler::keepRunning, this,
										boost::ref(my_service), boost::ref(my_timer)));
	}
}
开发者ID:Beirdo,项目名称:pion,代码行数:10,代码来源:PionScheduler.cpp

示例14: set_timeout

inline void wamp_dealer_invocation::set_timeout(timeout_callback callback, unsigned timeout_ms)
{
    // Do not allow setting a timeout value of 0 as this is a
    // special timeout value indicating infinite timeout. So
    // insted we just don't arm the timer which gives us an
    // infinite timeout.
    if (timeout_ms) {
        m_timeout_timer.expires_from_now(boost::posix_time::milliseconds(timeout_ms));
        m_timeout_timer.async_wait(callback);
    }
}
开发者ID:VinnyOG,项目名称:bonefish,代码行数:11,代码来源:wamp_dealer_invocation.hpp

示例15: handlers

 handlers(boost::asio::io_service& io_service, std::function<void()> callback)
   : callback(callback)
   , signals(io_service, SIGHUP, SIGTERM, SIGINT)
   , timer(io_service)
   , checkpoint_interval(boost::posix_time::hours(1))
 {
   signals.async_wait(boost::bind(&handlers::do_signal, this, _1, _2));
   // set the timer
   timer.expires_from_now(checkpoint_interval);
   timer.async_wait(boost::bind(&handlers::do_timer, this, _1));
 }
开发者ID:andreabedini,项目名称:isaw-sq-flatperm,代码行数:11,代码来源:main.cpp


注:本文中的boost::asio::deadline_timer::expires_from_now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。