1#ifndef LOGGING_EXECUTORSERVICE_H
2#define LOGGING_EXECUTORSERVICE_H
19 std::atomic<bool> m_exit =
false;
21 std::condition_variable m_conditionVariable;
22 typedef std::function<
void()> TASK;
23 std::queue<TASK> m_tasks;
24 std::thread m_runnable;
40 std::lock_guard<std::mutex>
lock(m_mutex);
43 m_conditionVariable.notify_all();
55 template<
class F,
class...
Args>
56 std::future<typename std::invoke_result<typename std::decay<F>::type,
typename std::decay<Args>::type...>::type>
60template<
class F,
class...
Args>
61std::future<typename std::invoke_result<typename std::decay<F>::type,
typename std::decay<Args>::type...>::type>
64 auto func = std::make_shared<std::packaged_task<
65 typename std::invoke_result<typename std::decay<F>::type,
typename std::decay<Args>::type...>::type()>>(
66 std::bind(std::forward<F>(
f), std::forward<Args>(
args)...));
67 auto future = func->get_future();
69 std::unique_lock<std::mutex>
lock(m_mutex);
70 m_tasks.push([=, func = std::move(func)]() { (*func)(); });
72 m_conditionVariable.notify_one();
Definition ExecutorService.h:17
std::future< typename std::invoke_result< typename std::decay< F >::type, typename std::decay< Args >::type... >::type > execute(F &&f, Args &&...args)
Definition ExecutorService.h:62
ExecutorService()
Definition ExecutorService.h:31
~ExecutorService()
Definition ExecutorService.h:34
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9