整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
54
util/Service.cpp
Normal file
54
util/Service.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "Service.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DEFINE
|
||||
*******************************************************************************
|
||||
*/
|
||||
namespace Util
|
||||
{
|
||||
|
||||
void Service::start()
|
||||
{
|
||||
if (isRunning())
|
||||
return;
|
||||
|
||||
_pThread = new Poco::Thread();
|
||||
try
|
||||
{
|
||||
_pThread->start(*this);
|
||||
}
|
||||
catch (Poco::Exception& e)
|
||||
{
|
||||
std::cout << " --> Service: Poco::Exception: " << e.displayText() << "(" << e.what() << ")" << std::endl;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cout << " --> Service: std::exception: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Service::stop()
|
||||
{
|
||||
if (isRunning())
|
||||
{
|
||||
cancel();
|
||||
_pThread->join();
|
||||
_pThread.reset();
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
bool Service::isRunning() const
|
||||
{
|
||||
return !_pThread.isNull() && _pThread->isRunning();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue