35 lines
980 B
C++
35 lines
980 B
C++
#ifndef DE82057F_5520_4849_8108_E9A31AAC1878
|
|
#define DE82057F_5520_4849_8108_E9A31AAC1878
|
|
/*
|
|
*******************************************************************************
|
|
* INCLUDE
|
|
*******************************************************************************
|
|
*/
|
|
#include <functional>
|
|
#include <Poco/Thread.h>
|
|
#include <Poco/SharedPtr.h>
|
|
|
|
namespace Util
|
|
{
|
|
/*
|
|
*******************************************************************************
|
|
* CLASS DECLARE
|
|
*******************************************************************************
|
|
*/
|
|
class ParallelRunner
|
|
{
|
|
public:
|
|
template <class Func, class... Args> void run(Func func, Args... args)
|
|
{
|
|
Poco::Thread* pThread = new Poco::Thread();
|
|
pThread->startFunc([=]() -> void { func(args...); });
|
|
_threads.push_back(pThread);
|
|
}
|
|
|
|
void join();
|
|
|
|
private:
|
|
std::vector<Poco::SharedPtr<Poco::Thread>> _threads;
|
|
};
|
|
}
|
|
#endif
|