예제 #1
0
 void on_open(connection_ptr connection) {
     if (!m_timer) {
         m_timer.reset(new boost::asio::deadline_timer(connection->get_io_service(),boost::posix_time::seconds(0)));
         m_timer->expires_from_now(boost::posix_time::milliseconds(250));
         m_timer->async_wait(boost::bind(&type::on_timer,this,boost::asio::placeholders::error));
     }
 
     m_connections.insert(connection);
 }
예제 #2
0
 void on_open(connection_ptr connection) {
     if (!m_timer) {
         m_timer.reset(new boost::asio::deadline_timer(connection->get_io_service(),boost::posix_time::seconds(0)));
         m_timer->expires_from_now(boost::posix_time::milliseconds(250));
         m_timer->async_wait(boost::bind(&type::on_timer,this,connection,boost::asio::placeholders::error));
     }
     
     m_connections_cur++;
     
     if (m_connections_cur == m_connections_max) {
         boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
         boost::posix_time::time_period period(m_start_time,now);
         int ms = period.length().total_milliseconds();
         
         std::cout << "started " << m_connections_cur << " in " << ms << "ms" << " (" << m_connections_cur/(ms/1000.0) << "/s)" << std::endl;
     }
 }
예제 #3
0
파일: case.cpp 프로젝트: 12w21/rippled
/// Starts a test by starting the timeout timer and marking the start time
void case_handler::start(connection_ptr con, uint64_t timeout) {
    if (timeout > 0) {
        m_timer.reset(new boost::asio::deadline_timer(
            con->get_io_service(),
            boost::posix_time::seconds(0))
        );
        
        m_timeout = timeout;
        
        m_timer->expires_from_now(boost::posix_time::milliseconds(m_timeout));
        m_timer->async_wait(
            boost::bind(
                &type::on_timer,
                this,
                con,
                boost::asio::placeholders::error
            )
        );
    }
    
    m_start = boost::chrono::steady_clock::now();
}