31 static void postTask(
const std::function<
void()> &func);
33 template<
class RETURN_TYPE>
34 static std::shared_future<RETURN_TYPE>
postTask(
const std::function<RETURN_TYPE()> &func);
36#ifdef SESE_PLATFORM_WINDOWS
39 std::function<void()> function;
42 template<
class RETURN_TYPE>
44 std::packaged_task<RETURN_TYPE()> packagedTask;
47 static DWORD WINAPI taskRunner1(LPVOID lp_param);
49 template<
class RETURN_TYPE>
50 static DWORD WINAPI taskRunner2(LPVOID lp_parma);
58#ifdef SESE_PLATFORM_WINDOWS
60template<
class RETURN_TYPE>
62 auto task2 =
new Task2<RETURN_TYPE>();
63 auto packaged_task = std::packaged_task<RETURN_TYPE()>(func);
64 std::shared_future<RETURN_TYPE> future(packaged_task.get_future());
65 task2->packagedTask = std::move(packaged_task);
66 QueueUserWorkItem(taskRunner2<RETURN_TYPE>, task2, WT_EXECUTEDEFAULT);
70template<
class RETURN_TYPE>
71DWORD sese::GlobalThreadPool::taskRunner2(LPVOID lp_parma) {
72 auto task2 =
static_cast<Task2<RETURN_TYPE> *
>(lp_parma);
73 task2->packagedTask();
80template<
class ReturnType>
82 auto pool = globalThreadPool.getInstance();
83 return pool->postTask<ReturnType>(func);