work on porting

This commit is contained in:
Matej Sekoranja
2014-05-19 22:33:40 +02:00
parent 4f63aba281
commit 2ef0abc67b
5 changed files with 394 additions and 241 deletions

View File

@@ -463,6 +463,37 @@ void RPCServer::run(int seconds)
m_serverContext->run(seconds);
}
struct ThreadRunnerParam {
RPCServer::shared_pointer server;
int timeToRun;
};
static void threadRunner(void* usr)
{
ThreadRunnerParam* pusr = static_cast<ThreadRunnerParam*>(usr);
ThreadRunnerParam param = *pusr;
delete pusr;
param.server->run(param.timeToRun);
}
/// Method requires usage of std::tr1::shared_ptr<RPCServer>. This instance must be
/// owned by a shared_ptr instance.
void RPCServer::runInNewThread(int seconds)
{
std::auto_ptr<ThreadRunnerParam> param(new ThreadRunnerParam());
param->server = rpcServer;
param->timeToRun = seconds;
epicsThreadCreate("RPCServer thread",
epicsThreadPriorityMedium,
epicsThreadGetStackSize(epicsThreadStackSmall),
threadRunner, param.get());
// let the thread delete 'param'
param.release();
}
void RPCServer::destroy()
{
m_serverContext->destroy();