39 #ifndef _uhal_ProtocolTCP_hpp_ 40 #define _uhal_ProtocolTCP_hpp_ 49 #include <boost/shared_ptr.hpp> 50 #include <boost/asio/io_service.hpp> 51 #include <boost/asio/ip/tcp.hpp> 52 #include <boost/asio/deadline_timer.hpp> 53 #include <boost/chrono/system_clocks.hpp> 55 #include <boost/thread/thread.hpp> 56 #include <boost/thread/mutex.hpp> 57 #include <boost/thread/condition_variable.hpp> 84 template < typename InnerProtocol ,
std::
size_t nr_buffers_per_send >
85 class
TCP : public InnerProtocol
102 TCP& operator= (
const TCP& aTCP );
110 TCP (
const std::string& aId,
const URI& aUri );
128 virtual void Flush( );
133 virtual void dispatchExceptionHandler();
139 uint32_t getMaxSendSize();
145 uint32_t getMaxReplySize();
164 void write_callback (
const boost::system::error_code& aErrorCode , std::size_t aBytesTransferred );
178 void read_callback (
const boost::system::error_code& aErrorCode , std::size_t aBytesTransferred );
183 void CheckDeadline();
189 void NotifyConditionalVariable (
const bool& aValue );
193 void WaitOnConditionalVariable();
223 std::deque < std::pair<std::vector< boost::shared_ptr< Buffers > >, SteadyClock_t::time_point> >
mReplyQueue;
263 std::pair< std::vector< boost::shared_ptr< Buffers > >, SteadyClock_t::time_point >
mReplyBuffers;
boost::condition_variable mConditionalVariable
A conditional variable for blocking the main thread until the variable with which it is associated is...
std::deque< std::pair< std::vector< boost::shared_ptr< Buffers > >, SteadyClock_t::time_point > > mReplyQueue
The list of buffers still awaiting a reply.
std::deque< boost::shared_ptr< Buffers > > mDispatchQueue
The list of buffers still waiting to be sent.
uint32_t mPacketsInFlight
Counter of how many writes have been sent, for which no reply has yet been received.
boost::asio::deadline_timer mDeadlineTimer
The mechanism for providing the time-out.
TimeIntervalStats mInterSendTimeStats
bool mFlushStarted
Boolean specifying whether or not the main thread is within TCP::Flush method. Its value checked by t...
uhal::exception::exception * mAsynchronousException
A pointer to an exception object for passing exceptions from the worker thread to the main thread...
SteadyClock_t::time_point mLastRecvQueued
SteadyClock_t::time_point mLastSendQueued
boost::asio::ip::tcp::resolver::iterator mEndpoint
A shared pointer to a boost::asio tcp endpoint - used by the delayed (open-on-first-use) connect...
#define UHAL_DEFINE_DERIVED_EXCEPTION_CLASS(ClassName, BaseClassName, ClassDescription)
Macro for simplifying the declaration and definition of derived exception types.
An abstract base exception class providing an interface to a throw/ThrowAsDerivedType mechanism which...
TimeIntervalStats mRTTStats
uint32_t mSendByteCounter
Variable storing "number of bytes to follow" field for the TCP chunk currently being sent...
boost::mutex mConditionalVariableMutex
A mutex for use by the conditional variable.
boost::mutex mTransportLayerMutex
A MutEx lock used to make sure the access functions are thread safe.
boost::chrono::steady_clock SteadyClock_t
boost::asio::io_service::work mIOserviceWork
Needed when multi-threading to stop the boost::asio::io_service thinking it has nothing to do and so ...
TimeIntervalStats mLSTStats
TimeIntervalStats mInterRecvTimeStats
std::pair< std::vector< boost::shared_ptr< Buffers > >, SteadyClock_t::time_point > mReplyBuffers
The buffers containing the payloads for the receive operation that's currently in progress...
boost::thread mDispatchThread
The Worker thread in Multi-threaded mode.
boost::asio::io_service mIOservice
The boost::asio::io_service used to create the connections.
Transport protocol to transfer an IPbus buffer via TCP.
uint32_t mReplyByteCounter
Variable used to store "number of bytes to follow" field for the next/current TCP chunk being receive...
std::vector< boost::shared_ptr< Buffers > > mDispatchBuffers
The buffers containing the payload for the send operation that's currently in progress.
bool mFlushDone
A variable associated with the conditional variable which specifies whether all packets have been sen...
boost::asio::ip::tcp::socket mSocket
A shared pointer to a boost::asio tcp socket through which the operation will be performed.
Struct to store a URI when parsed by boost spirit.