39#ifndef _uhal_ProtocolUDP_hpp_ 
   40#define _uhal_ProtocolUDP_hpp_ 
   43#include <condition_variable> 
   52#include <boost/asio/io_service.hpp> 
   53#include <boost/asio/ip/udp.hpp> 
   54#include <boost/asio/deadline_timer.hpp> 
   61  namespace system { 
class error_code; }
 
   81  template < typename InnerProtocol >
 
   82  class 
UDP : public InnerProtocol
 
  107      UDP ( 
const std::string& aId, 
const URI& aUri );
 
  118      void implementDispatch ( std::shared_ptr< Buffers > aBuffers );
 
  121      virtual void Flush( );
 
  124      virtual void dispatchExceptionHandler();
 
  130      uint32_t getMaxSendSize();
 
  136      uint32_t getMaxReplySize();
 
  153      void write_callback ( 
const boost::system::error_code& aErrorCode , std::size_t aBytesTransferred );
 
  167      void read_callback ( 
const boost::system::error_code& aErrorCode , std::size_t aBytesTransferred );
 
  170      void CheckDeadline();
 
  176      void NotifyConditionalVariable ( 
const bool& aValue );
 
  179      void WaitOnConditionalVariable();
 
Wrapper to generate a new Python exception type.
 
\rst Holds a reference to a Python object (no reference counting)
 
Transport protocol to transfer an IPbus buffer via UDP.
 
std::deque< std::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.
 
std::condition_variable mConditionalVariable
A conditional variable for blocking the main thread until the variable with which it is associated is...
 
std::mutex mConditionalVariableMutex
A mutex for use by the conditional variable.
 
std::mutex mTransportLayerMutex
A MutEx lock used to make sure the access functions are thread safe.
 
std::shared_ptr< Buffers > mDispatchBuffers
The send operation currently in progress.
 
boost::asio::io_service mIOservice
The boost::asio::io_service used to create the connections.
 
std::vector< uint8_t > mReplyMemory
A block of memory into which we write replies, before copying them to their final destination.
 
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::ip::udp::endpoint mEndpoint
A shared pointer to a boost::asio udp endpoint - used in the ASIO send and receive functions (UDP has...
 
std::deque< std::shared_ptr< Buffers > > mReplyQueue
The list of buffers still awaiting a reply.
 
UDP(const UDP &aUDP)
Copy Constructor This creates a new socket, dispatch queue, dispatch thread, etc.
 
bool mFlushDone
A variable associated with the conditional variable which specifies whether all packets have been sen...
 
boost::asio::deadline_timer mDeadlineTimer
The mechanism for providing the time-out.
 
std::thread mDispatchThread
The Worker thread in Multi-threaded mode.
 
size_t mMaxPayloadSize
The maximum UDP payload size (in bytes)
 
std::shared_ptr< Buffers > mReplyBuffers
The receive operation currently in progress or the next to be done.
 
boost::asio::ip::udp::socket mSocket
A shared pointer to a boost::asio udp socket through which the operation will be performed.
 
uhal::exception::exception * mAsynchronousException
A pointer to an exception object for passing exceptions from the worker thread to the main thread.
 
An abstract base exception class, including an interface to throw as the derived type (for passing ex...
 
#define UHAL_DEFINE_DERIVED_EXCEPTION_CLASS(ClassName, BaseClassName, ClassDescription)
Macro for simplifying the declaration and definition of derived exception types.
 
Struct to store a URI when parsed by boost spirit.