FougTools  0.7.0dev-046fb6a
Handy tools for C++, Qt and OpenCascade
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
runner_stdasync.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** FougTools
3 ** Copyright Fougue (30 Mar. 2015)
4 ** contact@fougue.pro
5 **
6 ** This software is a computer program whose purpose is to provide utility
7 ** tools for the C++ language and the Qt toolkit.
8 **
9 ** This software is governed by the CeCILL-C license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-C
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info".
14 ****************************************************************************/
15 
16 #pragma once
17 
18 #include "base_runner.h"
19 
20 #include <future>
21 
22 namespace qttask {
23 
24 struct StdAsync { };
25 
28 template<>
29 class Runner<StdAsync> : public BaseRunner
30 {
31 public:
32  Runner<StdAsync>(const Manager* mgr, std::launch policy = std::launch::async)
33  : BaseRunner(mgr),
34  m_isAbortRequested(false),
35  m_policy(policy)
36  { }
37 
38 protected:
39  bool isAbortRequested() override
40  { return m_isAbortRequested; }
41 
42  void requestAbort() override
43  { m_isAbortRequested = true; }
44 
45  void launch() override
46  { std::async(m_policy, [=] { this->execRunnableFunc(); } ); }
47 
48 private:
49  bool m_isAbortRequested;
50  std::launch m_policy;
51 };
52 
53 } // namespace qttask
void requestAbort() override
Definition: runner_stdasync.h:42
Base class for all runner objects.
Definition: base_runner.h:31
BaseRunner(const Manager *mgr)
Definition: base_runner.cpp:22
Definition: base_runner.h:73
bool isAbortRequested() override
Definition: runner_stdasync.h:39
Definition: runner_stdasync.h:24
Task runner based on std::async()
Definition: runner_stdasync.h:29
void launch() override
Definition: runner_stdasync.h:45
Central class providing management of tasks and notifications.
Definition: manager.h:32
void execRunnableFunc()
Definition: base_runner.cpp:71
Definition: base_runner.cpp:20