Jpp
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
InChannelHandler Class Reference

#include <input_channel_handler.hh>

Public Member Functions

void pause ()
 
void cont ()
 
 InChannelHandler (boost::asio::io_service &service, unsigned short port, FrameFarm &farm)
 
 ~InChannelHandler ()
 

Static Public Attributes

static const int recv_buf_size = 33554432
 

Private Member Functions

void handle (const boost::system::error_code &error, size_t size)
 

Private Attributes

boost::asio::ip::udp::socket m_socket
 
CLBDataGramm_buffer
 
FrameFarm *const m_farm
 
boost::atomic< bool > m_paused
 

Detailed Description

Author
cpellegrino

Definition at line 15 of file input_channel_handler.hh.

Constructor & Destructor Documentation

◆ InChannelHandler()

InChannelHandler::InChannelHandler ( boost::asio::io_service &  service,
unsigned short  port,
FrameFarm farm 
)
inline

Definition at line 61 of file input_channel_handler.hh.

64  :
65  m_socket(service, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), port)),
66  m_buffer(
67  InBufferCollector::getCollector().getEmptyDataGram()),
68  m_farm(&farm),
69  m_paused(false)
70  {
71  boost::asio::ip::udp::socket::receive_buffer_size option(recv_buf_size);
72  m_socket.set_option(option);
73  handle(boost::system::error_code(), 0);
74  }

◆ ~InChannelHandler()

InChannelHandler::~InChannelHandler ( )
inline

Definition at line 76 of file input_channel_handler.hh.

Member Function Documentation

◆ handle()

void InChannelHandler::handle ( const boost::system::error_code &  error,
size_t  size 
)
inlineprivate

Definition at line 22 of file input_channel_handler.hh.

23  {
24  // The error_code should be handled in principle, but
25  // it is not mandatory, since all possibilities should be already
26  // handled somewhere else.
27 
28  if (size && ! m_paused)
29  {
30  m_buffer->resize(size);
32 
34  }
35 
36  m_socket.async_receive(
37  boost::asio::buffer(m_buffer->raw(), m_buffer->capacity()),
38  boost::bind(
40  this,
41  boost::asio::placeholders::error,
42  boost::asio::placeholders::bytes_transferred));
43  }

◆ pause()

void InChannelHandler::pause ( )
inline

Definition at line 51 of file input_channel_handler.hh.

52  {
53  m_paused = true;
54  }

◆ cont()

void InChannelHandler::cont ( )
inline

Definition at line 56 of file input_channel_handler.hh.

57  {
58  m_paused = false;
59  }

Member Data Documentation

◆ m_socket

boost::asio::ip::udp::socket InChannelHandler::m_socket
private

Definition at line 17 of file input_channel_handler.hh.

◆ m_buffer

CLBDataGram* InChannelHandler::m_buffer
private

Definition at line 18 of file input_channel_handler.hh.

◆ m_farm

FrameFarm* const InChannelHandler::m_farm
private

Definition at line 19 of file input_channel_handler.hh.

◆ m_paused

boost::atomic<bool> InChannelHandler::m_paused
private

Definition at line 20 of file input_channel_handler.hh.

◆ recv_buf_size

const int InChannelHandler::recv_buf_size = 33554432
static

Definition at line 49 of file input_channel_handler.hh.


The documentation for this class was generated from the following file:
InBufferCollector::putDataGram
void putDataGram(CLBDataGram *p)
Definition: input_buffer_collector.hh:53
InChannelHandler::m_socket
boost::asio::ip::udp::socket m_socket
Definition: input_channel_handler.hh:17
CLBDataGram::resize
void resize(size_t s)
Definition: clb_datagram.hh:54
InChannelHandler::m_farm
FrameFarm *const m_farm
Definition: input_channel_handler.hh:19
InBufferCollector::getEmptyDataGram
CLBDataGram * getEmptyDataGram()
Definition: input_buffer_collector.hh:34
CLBDataGram::capacity
size_t capacity() const
Definition: clb_datagram.hh:75
InChannelHandler::handle
void handle(const boost::system::error_code &error, size_t size)
Definition: input_channel_handler.hh:22
CLBDataGram::raw
char * raw()
Definition: clb_datagram.hh:65
FrameFarm::insert
bool insert(CLBDataGram *datagram)
Definition: frame_farm.cc:98
InChannelHandler::recv_buf_size
static const int recv_buf_size
Definition: input_channel_handler.hh:49
InChannelHandler::m_buffer
CLBDataGram * m_buffer
Definition: input_channel_handler.hh:18
InBufferCollector::getCollector
static InBufferCollector & getCollector()
Definition: input_buffer_collector.hh:27
InChannelHandler::m_paused
boost::atomic< bool > m_paused
Definition: input_channel_handler.hh:20