00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #ifndef __PION_TCP_TIMER_HEADER__
00011 #define __PION_TCP_TIMER_HEADER__
00012 
00013 #include <boost/asio.hpp>
00014 #include <boost/bind.hpp>
00015 #include <boost/shared_ptr.hpp>
00016 #include <boost/enable_shared_from_this.hpp>
00017 #include <boost/thread/mutex.hpp>
00018 #include <pion/config.hpp>
00019 #include <pion/tcp/connection.hpp>
00020 
00021 
00022 namespace pion {    
00023 namespace tcp {     
00024 
00025 
00029 class timer
00030     : public boost::enable_shared_from_this<timer>
00031 {
00032 public:
00033 
00039     timer(tcp::connection_ptr& conn_ptr);
00040 
00046     void start(const boost::uint32_t seconds);
00047 
00049     void cancel(void);
00050 
00051 
00052 private:
00053 
00059     void timer_callback(const boost::system::error_code& ec);
00060 
00062     tcp::connection_ptr                     m_conn_ptr;
00063 
00065     boost::asio::deadline_timer             m_timer;
00066     
00068     boost::mutex                            m_mutex;
00069 
00071     bool                                    m_timer_active; 
00072 
00074     bool                                    m_was_cancelled;    
00075 };
00076 
00077 
00079 typedef boost::shared_ptr<timer>     timer_ptr;
00080 
00081 
00082 }   
00083 }   
00084 
00085 #endif