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

FXCompletion.h
1 /********************************************************************************
2 * *
3 * C o m p l e t i o n C o u n t e r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2014,2022 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 FXCOMPLETION_H
22 #define FXCOMPLETION_H
23 
24 
25 namespace FX {
26 
27 
28 class FXThreadPool;
29 
41 class FXAPI FXCompletion {
42 private:
43  FXSemaphore semaphore; // Signalled when last task done
44  volatile FXuint counter; // Task counter
45 private:
46  FXCompletion(const FXCompletion&);
47  FXCompletion& operator=(const FXCompletion&);
48 public:
49 
51  FXCompletion();
52 
54  FXuint count() const { return counter; }
55 
57  void increment(FXuint cnt=1);
58 
60  void decrement(FXuint cnt=1);
61 
63  void wait();
64 
66  FXbool wait(FXTime nsec);
67 
69  FXbool done() const { return (counter==0); }
70 
72  ~FXCompletion();
73  };
74 
75 }
76 
77 #endif
78 
A semaphore allows for protection of a resource that can be accessed by a fixed number of simultaneou...
Definition: FXSemaphore.h:38
FXbool done() const
Return true if count is zero.
Definition: FXCompletion.h:69
Definition: FX4Splitter.h:28
A completion counter allows a single thread to monitor a number of ongoing concurrent activities for ...
Definition: FXCompletion.h:41
FXuint count() const
Return current counter value.
Definition: FXCompletion.h:54

Copyright © 1997-2022 Jeroen van der Zijp