Newer
Older
namespace MetadataExporter_ns
{
//==============================================================================
// Server::Server()
//==============================================================================
Server::Server(Tango::DeviceImpl* deviceImpl_p, Configuration::SP configuration_sp) :
Tango::LogAdapter(deviceImpl_p), m_deviceImpl_p(deviceImpl_p),
m_configuration_sp(configuration_sp)
{
DEBUG_STREAM << "Server::Server()" << endl;
m_ioService_sp.reset(new boost::asio::io_service);
m_work_sp.reset(new boost::asio::io_service::work(*m_ioService_sp));
}
//==============================================================================
// Server::Server()
//==============================================================================
Server::~Server()
{
DEBUG_STREAM << "Server::~Server()" << endl;
m_ioService_sp->stop();
if(m_threadGroup_sp)
{
m_threadGroup_sp->interrupt_all();
m_threadGroup_sp->join_all();
}
}
//==============================================================================
// Server::start()
//==============================================================================
void Server::start()
{
DEBUG_STREAM << "Server::start()" << endl;
m_threadGroup_sp.reset(new boost::thread_group);
unsigned int workerNumber = m_configuration_sp->getWorkerNumber();
WorkerThread worker(m_deviceImpl_p, m_ioService_sp);
for(unsigned int i=0; i<workerNumber; ++i)
m_threadGroup_sp->add_thread(new boost::thread(&WorkerThread::run, worker));
}
//==============================================================================
// Server::stop()
//==============================================================================
void Server::stop()
{
DEBUG_STREAM << "Server::stop()" << endl;
m_ioService_sp->stop();
if(m_threadGroup_sp)
{
m_threadGroup_sp->interrupt_all();
m_threadGroup_sp->join_all();
}
}
//==============================================================================
// Server::startAccept()
//==============================================================================
void Server::startAccept()
{
DEBUG_STREAM << "Server::startAccept()" << endl;
}
//==============================================================================
// Server::handleAccept()
//==============================================================================
void Server::handleAccept()
{
DEBUG_STREAM << "Server::handleAccept()" << endl;
}
} //namespace