39 #ifndef _uhal_ProtocolUDP_hpp_ 40 #define _uhal_ProtocolUDP_hpp_ 49 #include <boost/shared_ptr.hpp> 50 #include <boost/asio/io_service.hpp> 51 #include <boost/asio/ip/udp.hpp> 52 #include <boost/asio/deadline_timer.hpp> 54 #include <boost/thread/thread.hpp> 55 #include <boost/thread/mutex.hpp> 56 #include <boost/thread/condition_variable.hpp> 63 namespace system {
class error_code; }
83 template <
typename InnerProtocol >
84 class UDP :
public InnerProtocol
101 UDP& operator= (
const UDP& aUDP );
111 UDP (
const std::string& aId,
const URI& aUri );
129 virtual void Flush( );
134 virtual void dispatchExceptionHandler();
140 uint32_t getMaxSendSize();
146 uint32_t getMaxReplySize();
163 void write_callback (
const boost::system::error_code& aErrorCode , std::size_t aBytesTransferred );
177 void read_callback (
const boost::system::error_code& aErrorCode , std::size_t aBytesTransferred );
182 void CheckDeadline();
188 void NotifyConditionalVariable (
const bool& aValue );
193 void WaitOnConditionalVariable();
std::deque< boost::shared_ptr< Buffers > > mDispatchQueue
The list of buffers still waiting to be sent.
Transport protocol to transfer an IPbus buffer via UDP.
boost::asio::io_service mIOservice
The boost::asio::io_service used to create the connections.
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.
#define UHAL_DEFINE_DERIVED_EXCEPTION_CLASS(ClassName, BaseClassName, ClassDescription)
Macro for simplifying the declaration and definition of derived exception types.
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 ...
An abstract base exception class providing an interface to a throw/ThrowAsDerivedType mechanism which...
boost::shared_ptr< Buffers > mReplyBuffers
The receive operation currently in progress or the next to be done.
boost::shared_ptr< Buffers > mDispatchBuffers
The send operation currently in progress.
boost::mutex mTransportLayerMutex
A MutEx lock used to make sure the access functions are thread safe.
boost::condition_variable mConditionalVariable
A conditional variable for blocking the main thread until the variable with which it is associated is...
boost::asio::ip::udp::socket mSocket
A shared pointer to a boost::asio udp socket through which the operation will be performed.
boost::thread mDispatchThread
The Worker thread in Multi-threaded mode.
std::vector< uint8_t > mReplyMemory
A block of memory into which we write replies, before copying them to their final destination...
std::deque< boost::shared_ptr< Buffers > > mReplyQueue
The list of buffers still awaiting a reply.
bool mFlushDone
A variable associated with the conditional variable which specifies whether all packets have been sen...
boost::asio::ip::udp::endpoint mEndpoint
A shared pointer to a boost::asio udp endpoint - used in the ASIO send and receive functions (UDP has...
uhal::exception::exception * mAsynchronousException
A pointer to an exception object for passing exceptions from the worker thread to the main thread...
boost::mutex mConditionalVariableMutex
A mutex for use by the conditional variable.
Struct to store a URI when parsed by boost spirit.