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

FXWSQueue.h
1 /********************************************************************************
2 * *
3 * W o r k - S t e a l i n g Q u e u e *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2016,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 FXWSQUEUE_H
22 #define FXWSQUEUE_H
23 
24 namespace FX {
25 
26 
28 class FXAPI FXWSQueue {
29 private:
30  FXPtrList list;
31  volatile FXint top;
32  volatile FXint bot;
33 private:
34  FXWSQueue(const FXWSQueue&);
35  FXWSQueue &operator=(const FXWSQueue&);
36 public:
37 
39  FXWSQueue(FXint sz=256);
40 
42  FXbool setSize(FXint sz);
43 
45  FXint getSize() const { return list.no(); }
46 
48  FXint getUsed() const;
49 
51  FXint getFree() const;
52 
54  FXbool isFull() const;
55 
57  FXbool isEmpty() const;
58 
60  FXbool push(FXptr ptr);
61 
63  FXbool pop(FXptr& ptr);
64 
66  FXbool take(FXptr& ptr);
67 
69  virtual ~FXWSQueue();
70  };
71 
72 }
73 
74 #endif
75 
FXint getSize() const
Return size.
Definition: FXWSQueue.h:45
Work-stealing queue.
Definition: FXWSQueue.h:28
Definition: FX4Splitter.h:28
FXival no() const
Return number of objects.
Definition: FXPtrList.h:55
List of void pointers.
Definition: FXPtrList.h:28

Copyright © 1997-2022 Jeroen van der Zijp