Code::Blocks  SVN r11506
cbthreadedtask.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  */
5 
6 #ifndef CBTHREADEDTASK_H
7 #define CBTHREADEDTASK_H
8 
14 {
15  public:
18 
20  virtual ~cbThreadedTask() = 0;
21 
23  void Abort();
24 
27  virtual int Execute() = 0;
28 
29  protected:
31  bool TestDestroy() const;
32 
34  bool Aborted() const;
35 
36  private:
37  bool m_abort;
38 };
39 
40 /* ************************************************ */
41 /* **************** INLINE MEMBERS **************** */
42 /* ************************************************ */
43 
45 : m_abort(false)
46 {
47  // empty
48 }
49 
51 {
52  // empty
53 }
54 
55 inline bool cbThreadedTask::TestDestroy() const
56 {
57  return m_abort;
58 }
59 
60 inline bool cbThreadedTask::Aborted() const
61 {
62  return m_abort;
63 }
64 
65 inline void cbThreadedTask::Abort()
66 {
67  m_abort = true;
68 }
69 
70 #endif
virtual int Execute()=0
Override this function with the task's job Return value doesn't matter.
bool TestDestroy() const
Be sure to call this function often. If it returns true, quit your task quickly.
virtual ~cbThreadedTask()=0
cbThreadedTask dtor
void Abort()
This function is called to tell the task to abort (check cbThreadPool::AbortAllTasks) ...
cbThreadedTask()
cbThreadedTask ctor
This is what you have to use instead of wxThread to add tasks to the Thread Pool. ...
bool Aborted() const
Same as TestDestroy()