|
μHAL (v2.7.9)
Part of the IPbus software repository
|
Go to the documentation of this file.
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
109 UDP (
const std::string& aId,
const URI& aUri );
123 virtual void Flush( );
126 virtual void dispatchExceptionHandler();
132 uint32_t getMaxSendSize();
138 uint32_t getMaxReplySize();
155 void write_callback (
const boost::system::error_code& aErrorCode , std::size_t aBytesTransferred );
169 void read_callback (
const boost::system::error_code& aErrorCode , std::size_t aBytesTransferred );
172 void CheckDeadline();
178 void NotifyConditionalVariable (
const bool& aValue );
181 void WaitOnConditionalVariable();
std::deque< boost::shared_ptr< Buffers > > mDispatchQueue
The list of buffers still waiting to be sent.
boost::mutex mConditionalVariableMutex
A mutex for use by the conditional variable.
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 ...
boost::asio::deadline_timer mDeadlineTimer
The mechanism for providing the time-out.
boost::shared_ptr< Buffers > mReplyBuffers
The receive operation currently in progress or the next to be done.
#define UHAL_DEFINE_DERIVED_EXCEPTION_CLASS(ClassName, BaseClassName, ClassDescription)
Macro for simplifying the declaration and definition of derived exception types.
boost::asio::io_service mIOservice
The boost::asio::io_service used to create the connections.
An abstract base exception class, including an interface to throw as the derived type (for passing ex...
boost::mutex mTransportLayerMutex
A MutEx lock used to make sure the access functions are thread safe.
Transport protocol to transfer an IPbus buffer via UDP.
std::vector< uint8_t > mReplyMemory
A block of memory into which we write replies, before copying them to their final destination.
UDP(const UDP &aUDP)
Copy Constructor This creates a new socket, dispatch queue, dispatch thread, etc.
boost::thread mDispatchThread
The Worker thread in Multi-threaded mode.
boost::shared_ptr< Buffers > mDispatchBuffers
The send operation currently in progress.
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...
boost::asio::ip::udp::socket mSocket
A shared pointer to a boost::asio udp socket through which the operation will be performed.
uint32_t mPacketsInFlight
Counter of how many writes have been sent, for which no reply has yet been received.
std::deque< boost::shared_ptr< Buffers > > mReplyQueue
The list of buffers still awaiting a reply.
uhal::exception::exception * mAsynchronousException
A pointer to an exception object for passing exceptions from the worker thread to the main thread.
Struct to store a URI when parsed by boost spirit.
boost::condition_variable mConditionalVariable
A conditional variable for blocking the main thread until the variable with which it is associated is...
bool mFlushDone
A variable associated with the conditional variable which specifies whether all packets have been sen...