p26001-store-acs-soc-fw-app/util/ParallelRunner.h
2026-09-28 21:33:04 +08:00

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