void cia_client::do_timeout_check()
{
	if (m_started_)
	{
		m_check_timeout_timer.expires_from_now(boost::posix_time::milliseconds(TIMEOUT_CHECK_ELAPSED));
		ptr self = shared_from_this();
		//BOOST_LOG_SEV(cia_g_logger, AllEvent) << "开始准备异步检测超时, 触发检测的时间是在"
		//	<< TIMEOUT_CHECK_ELAPSED << "毫秒后, " << "客户端socket超时时间设置为" << m_timeout_elapsed << "毫秒";
		m_check_timeout_timer.async_wait([this, self](const error_code& ec){
			if (ec)
			{
				BOOST_LOG_SEV(cia_g_logger, Debug) << "已停止超时检测";
				stop();
				return;
			}
			std::size_t elapsed_time_ = std::size_t(m_update_time.elapsed().wall / 1000000);
			if (elapsed_time_ > m_timeout_elapsed) {
				BOOST_LOG_SEV(cia_g_logger, Debug) << "客户端因超时关闭, 已经在"
					<< elapsed_time_ << "毫秒内无任何动作";
				stop();
			}
			else if (elapsed_time_ > m_timeout_elapsed / 2) {
				BOOST_LOG_SEV(cia_g_logger, AllEvent) << "向客户端发送心跳请求, 已经在"
					<< elapsed_time_ << "毫秒内无任何动作";
				do_deal_heart_request();
			}
			do_timeout_check();
		});
	}
}
void checkFinish(int x)
{
	if (x == 0)
	{
		ElapsedTime = Timer.elapsed();
		Mutex.unlock();
	}
}
 void dump(boost::timer::cpu_timer& timer, 
           std::string const& action,
           unsigned count,
           bool warm)
 {
   uint64_t elapsed = timer.elapsed().wall;
   double avg = elapsed < _timer_delay ? 0.0 :
                static_cast<double>(elapsed-_timer_delay)/count;
   _out << _name << "|" << action << "|" << count << "|" 
     << to_string(warm) << "|" << avg << std::endl;
   _out.flush();
 }
	/**
	* \brief 获取通道被占用的时间
	*
	* \return 返回 获取通道被占用的时间, 单位:毫秒
	*/
	std::size_t elpased()
	{
		return (std::size_t)(m_callTime.elapsed().wall / 1000000);
	}
Beispiel #5
0
	static inline int64_t Get() {
		return boost_clock.elapsed().wall;
	}
Beispiel #6
0
 void measureElapsed(boost::timer::cpu_timer const& timer) {
   boost::timer::cpu_times elapsed(timer.elapsed());
   const double ns = 1e-9;
   sec = elapsed.user * ns;
   wallSec = elapsed.wall * ns;
 }