Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
DataInputInterface Class Reference

#include <data_input_interface.hh>

Public Member Functions

 DataInputInterface (size_t number_of_workers=1)
 
 ~DataInputInterface ()
 
void stop ()
 
void pause ()
 
void cont ()
 
void start ()
 
void add_worker ()
 
void add_channel (unsigned short port, FrameFarm &farm)
 

Private Attributes

size_t m_number_of_workers
 
std::vector< InChannelHandler * > m_channel_handlers
 
boost::asio::io_service m_service
 
boost::scoped_ptr< boost::thread_group > m_threads
 

Detailed Description

Author
cpellegrino

Definition at line 18 of file data_input_interface.hh.

Constructor & Destructor Documentation

◆ DataInputInterface()

DataInputInterface::DataInputInterface ( size_t number_of_workers = 1)
inline

Definition at line 27 of file data_input_interface.hh.

28 :
29 m_number_of_workers(number_of_workers),
30 m_threads(0)
31 {}
boost::scoped_ptr< boost::thread_group > m_threads

◆ ~DataInputInterface()

DataInputInterface::~DataInputInterface ( )
inline

Definition at line 33 of file data_input_interface.hh.

34 {
35 stop();
36 for (size_t i = 0; i < m_channel_handlers.size(); ++i)
37 {
38 delete m_channel_handlers[i];
39 }
40 }
std::vector< InChannelHandler * > m_channel_handlers

Member Function Documentation

◆ stop()

void DataInputInterface::stop ( )
inline

Definition at line 42 of file data_input_interface.hh.

43 {
44 m_service.stop();
45
46 if (m_threads)
47 {
48 m_threads->join_all();
49 }
50
51 m_threads.reset();
52 }
boost::asio::io_service m_service

◆ pause()

void DataInputInterface::pause ( )
inline

Definition at line 54 of file data_input_interface.hh.

55 {
56 BOOST_FOREACH(InChannelHandler* h, m_channel_handlers)
57 {
58 h->pause();
59 }
60 }

◆ cont()

void DataInputInterface::cont ( )
inline

Definition at line 62 of file data_input_interface.hh.

63 {
64 BOOST_FOREACH(InChannelHandler* h, m_channel_handlers)
65 {
66 h->cont();
67 }
68 }

◆ start()

void DataInputInterface::start ( )
inline

Definition at line 70 of file data_input_interface.hh.

71 {
72 assert(!m_threads && "Calling DataInputInterface::start() on started istance.");
73
74 m_threads.reset(new boost::thread_group);
75 m_service.reset();
76 for (std::size_t i = 0; i < m_number_of_workers; ++i)
77 {
78 m_threads->create_thread(boost::bind(&boost::asio::io_service::run,
79 &m_service));
80 }
81 }

◆ add_worker()

void DataInputInterface::add_worker ( )
inline

Definition at line 83 of file data_input_interface.hh.

84 {
85 if (m_threads)
86 {
87 m_threads->create_thread(boost::bind(&boost::asio::io_service::run,
88 &m_service));
89 }
90
92 }

◆ add_channel()

void DataInputInterface::add_channel ( unsigned short port,
FrameFarm & farm )
inline

Definition at line 94 of file data_input_interface.hh.

95 {
96 InChannelHandler* new_channel = new InChannelHandler(m_service, port, farm);
97 m_channel_handlers.push_back(new_channel);
98 }

Member Data Documentation

◆ m_number_of_workers

size_t DataInputInterface::m_number_of_workers
private

Definition at line 20 of file data_input_interface.hh.

◆ m_channel_handlers

std::vector<InChannelHandler*> DataInputInterface::m_channel_handlers
private

Definition at line 21 of file data_input_interface.hh.

◆ m_service

boost::asio::io_service DataInputInterface::m_service
private

Definition at line 22 of file data_input_interface.hh.

◆ m_threads

boost::scoped_ptr<boost::thread_group> DataInputInterface::m_threads
private

Definition at line 23 of file data_input_interface.hh.


The documentation for this class was generated from the following file: