Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXTaskGroup.h
1 /********************************************************************************
2 * *
3 * T a s k G r o u p C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2012,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXTASKGROUP_H
22 #define FXTASKGROUP_H
23 
24 namespace FX {
25 
26 
27 class FXThreadPool;
28 
29 
48 class FXAPI FXTaskGroup {
49 private:
50  class Task : public FXRunnable {
51  private:
52  FXTaskGroup *taskgroup; // Backlink to taskgroup
53  FXRunnable *runnable; // Wrapped runnable
54  private:
55  Task(const Task&);
56  Task &operator=(const Task&);
57  public:
58  Task(FXTaskGroup* g,FXRunnable *r);
59  virtual FXint run();
60  virtual ~Task();
61  };
62 private:
63  FXThreadPool *threadpool; // Thread pool used by task group
64  FXCompletion completion; // Completion counter
65 private:
66  FXTaskGroup(const FXTaskGroup&);
67  FXTaskGroup &operator=(const FXTaskGroup&);
68 public:
69 
74  FXTaskGroup();
75 
80 
84  FXThreadPool* getThreadPool() const { return threadpool; }
85 
89  FXuint getRunningTasks() const { return completion.count(); }
90 
94  FXbool execute(FXRunnable* task);
95 
101  FXbool executeAndWait(FXRunnable* task);
102 
108  FXbool wait();
109 
113  virtual ~FXTaskGroup();
114  };
115 
116 }
117 
118 #endif

Copyright © 1997-2016 Jeroen van der Zijp