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_qthreadpool.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 <QtCore/QRunnable>
21 #include <QtCore/QThreadPool>
22 
23 namespace qttask {
24 
29 template<>
30 class Runner<QThreadPool> : public QRunnable, public BaseRunner
31 {
32 public:
36  Runner<QThreadPool>(const Manager* mgr, int priority = 0)
37  : BaseRunner(mgr),
38  m_isAbortRequested(false),
39  m_priority(priority)
40  {
41  this->setAutoDelete(false);
42  }
43 
44  void run() override // -- QRunnable
45  { this->execRunnableFunc(); }
46 
47  bool isAbortRequested() override
48  { return m_isAbortRequested; }
49 
50  void requestAbort() override
51  { m_isAbortRequested = true; }
52 
53  void launch() override
54  { QThreadPool::globalInstance()->start(this, m_priority); }
55 
56 private:
57  bool m_isAbortRequested;
58  int m_priority;
59 };
60 
61 } // namespace qttask
void launch() override
Definition: runner_qthreadpool.h:53
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
Task runner using the global instance of QThreadPool.
Definition: runner_qthreadpool.h:30
bool isAbortRequested() override
Definition: runner_qthreadpool.h:47
void requestAbort() override
Definition: runner_qthreadpool.h:50
Central class providing management of tasks and notifications.
Definition: manager.h:32
void run() override
Definition: runner_qthreadpool.h:44
void execRunnableFunc()
Definition: base_runner.cpp:71
Definition: base_runner.cpp:20