net/include/pion/net/TCPTimer.hpp

00001 // ------------------------------------------------------------------
00002 // pion-net: a C++ framework for building lightweight HTTP interfaces
00003 // ------------------------------------------------------------------
00004 // Copyright (C) 2007-2010 Atomic Labs, Inc.  (http://www.atomiclabs.com)
00005 //
00006 // Distributed under the Boost Software License, Version 1.0.
00007 // See http://www.boost.org/LICENSE_1_0.txt
00008 //
00009 
00010 #ifndef __PION_TCPTIMER_HEADER__
00011 #define __PION_TCPTIMER_HEADER__
00012 
00013 #include <boost/asio.hpp>
00014 #include <boost/shared_ptr.hpp>
00015 #include <boost/enable_shared_from_this.hpp>
00016 #include <boost/thread/mutex.hpp>
00017 #include <pion/PionConfig.hpp>
00018 #include <pion/net/TCPConnection.hpp>
00019 
00020 
00021 namespace pion {    // begin namespace pion
00022 namespace net {     // begin namespace net (Pion Network Library)
00023 
00024 
00028 class TCPTimer
00029     : public boost::enable_shared_from_this<TCPTimer>
00030 {
00031 public:
00032 
00038     TCPTimer(TCPConnectionPtr& conn_ptr);
00039 
00045     void start(const boost::uint32_t seconds);
00046 
00048     void cancel(void);
00049 
00050 
00051 private:
00052 
00058     void timerCallback(const boost::system::error_code& ec);
00059 
00060 
00062     TCPConnectionPtr                        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<TCPTimer>     TCPTimerPtr;
00080 
00081 
00082 }   // end namespace net
00083 }   // end namespace pion
00084 
00085 #endif

Generated on Fri Apr 30 14:48:53 2010 for pion-net by  doxygen 1.4.7