hikyuu2/hikyuu_cpp/hikyuu/global/GlobalTaskGroup.h

43 lines
837 B
C++
Raw Normal View History

/*
* GlobalTaskGroup.h
*
* Copyright (c) 2019 hikyuu.org
*
* Created on: 2020-4-20
* Author: fasiondog
*/
2020-05-17 17:38:05 +08:00
#pragma once
#ifndef HKU_GLOBAL_TASK_GROUP
#define HKU_GLOBAL_TASK_GROUP
2021-01-15 00:19:38 +08:00
#include "../utilities/thread/StealThreadPool.h"
namespace hku {
/**
* 线
* @note 使 future
*/
2021-01-15 00:19:38 +08:00
StealThreadPool* getGlobalTaskGroup();
2020-04-25 23:55:52 +08:00
template <typename ResultType>
using task_handle = std::future<ResultType>;
/**
*
*/
template <typename FunctionType>
task_handle<typename std::result_of<FunctionType()>::type> addTask(FunctionType f) {
return getGlobalTaskGroup()->submit(f);
}
2021-01-15 00:19:38 +08:00
/**
* 退
*/
2021-01-15 00:19:38 +08:00
void releaseGlobalTaskGroup();
} /* namespace hku */
#endif /* HKU_GLOBAL_TASK_GROUP */