10 #include <pion/net/TCPTimer.hpp>
11 #include <boost/bind.hpp>
21 : m_conn_ptr(conn_ptr), m_timer(conn_ptr->getIOService()),
22 m_timer_active(false), m_was_cancelled(false)
28 boost::mutex::scoped_lock timer_lock(m_mutex);
29 m_timer_active =
true;
30 m_timer.expires_from_now(boost::posix_time::seconds(seconds));
31 m_timer.async_wait(boost::bind(&TCPTimer::timerCallback,
32 shared_from_this(), _1));
37 boost::mutex::scoped_lock timer_lock(m_mutex);
38 m_was_cancelled =
true;
43 void TCPTimer::timerCallback(
const boost::system::error_code& ec)
45 boost::mutex::scoped_lock timer_lock(m_mutex);
46 m_timer_active =
false;
47 if (! m_was_cancelled)
TCPTimer(TCPConnectionPtr &conn_ptr)
void start(const boost::uint32_t seconds)
void cancel(void)
cancel the timer (operation completed)