HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_WorkItemStateTracker.h
Go to the documentation of this file.
1 /*
2 * PROPRIETARY INFORMATION. This software is proprietary to
3 * Side Effects Software Inc., and is not to be reproduced,
4 * transmitted, or disclosed in any way without written permission.
5 *
6 * COMMENTS:
7 */
8 
9 #ifndef __PDG_WORKITEM_STATETRACKER_H__
10 #define __PDG_WORKITEM_STATETRACKER_H__
11 
12 #include "PDG_API.h"
13 #include "PDG_Types.h"
14 
15 #include <SYS/SYS_AtomicInt.h>
16 
17 /*
18  * Helper class that maintains a list of work item state counts
19  */
21 {
22 public:
24  { reset(); }
25 
26  inline void reset()
27  {
28  myWorkItemCount.store(0);
29  for (int i = 0;
31  i++)
32  {
33  myStateCounts[i].store(0);
34  }
35  }
36 
37  inline int workItemCount() const
38  { return myWorkItemCount.relaxedLoad(); }
39 
40  inline int stateCount(PDG_WorkItemState state) const
41  { return stateCounter(state).relaxedLoad(); }
42 
43  inline void addWorkItem(PDG_WorkItemState state)
44  {
45  stateCounter(state).add(1);
46  myWorkItemCount.add(1);
47  }
48 
49  inline void removeWorkItem(PDG_WorkItemState state)
50  {
51  stateCounter(state).add(-1);
52  myWorkItemCount.add(-1);
53  }
54 
55  inline void updateWorkItem(
56  PDG_WorkItemState prev,
58  {
59  stateCounter(prev).add(-1);
60  stateCounter(cur).add(1);
61  }
62 
63 private:
64  SYS_AtomicInt32& stateCounter(PDG_WorkItemState state)
65  { return myStateCounts[(int)state]; }
66  const SYS_AtomicInt32& stateCounter(PDG_WorkItemState state) const
67  { return myStateCounts[(int)state]; }
68 
69 private:
70  SYS_AtomicInt32 myWorkItemCount;
72 };
73 
74 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
The number of states.
#define PDG_API
Definition: PDG_API.h:23
GLboolean reset
Definition: glad.h:5138
PDG_WorkItemState
Enum of possible work item states.
Definition: PDG_Types.h:413
void updateWorkItem(PDG_WorkItemState prev, PDG_WorkItemState cur)
int stateCount(PDG_WorkItemState state) const
void removeWorkItem(PDG_WorkItemState state)
void addWorkItem(PDG_WorkItemState state)