SST  12.0.1
StructuralSimulationToolkit
syncQueue.h
1 // Copyright 2009-2022 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2022, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_SYNC_SYNCQUEUE_H
13 #define SST_CORE_SYNC_SYNCQUEUE_H
14 
15 #include "sst/core/activityQueue.h"
16 #include "sst/core/threadsafe.h"
17 
18 #include <vector>
19 
20 namespace SST {
21 
22 /**
23  * \class SyncQueue
24  *
25  * Internal API
26  *
27  * Activity Queue for use by Sync Objects
28  */
29 class SyncQueue : public ActivityQueue
30 {
31 public:
32  struct Header
33  {
34  uint32_t mode;
35  uint32_t count;
36  uint32_t buffer_size;
37  };
38 
39  SyncQueue();
40  ~SyncQueue();
41 
42  bool empty() override;
43  int size() override;
44  void insert(Activity* activity) override;
45  Activity* pop() override; // Not a good idea for this particular class
46  Activity* front() override;
47 
48  // Not part of the ActivityQueue interface
49  /** Clear elements from the queue */
50  void clear();
51  /** Accessor method to the internal queue */
52  char* getData();
53 
54  uint64_t getDataSize() { return buf_size + (activities.capacity() * sizeof(Activity*)); }
55 
56 private:
57  char* buffer;
58  size_t buf_size;
59  std::vector<Activity*> activities;
60 
62 };
63 
64 } // namespace SST
65 
66 #endif // SST_CORE_SYNC_SYNCQUEUE_H
Activity * front() override
Returns the next activity.
Definition: syncQueue.cc:77
Activity * pop() override
Remove and return the next activity.
Definition: syncQueue.cc:65
Base class for all Activities in the SST Event Queue.
Definition: activity.h:46
char * getData()
Accessor method to the internal queue.
Definition: syncQueue.cc:91
Definition: syncQueue.h:32
int size() override
Returns the number of activities in the queue.
Definition: syncQueue.cc:37
bool empty() override
Returns true if the queue is empty.
Definition: syncQueue.cc:30
void clear()
Clear elements from the queue.
Definition: syncQueue.cc:84
Definition: threadsafe.h:121
Internal API.
Definition: syncQueue.h:29
void insert(Activity *activity) override
Insert a new activity into the queue.
Definition: syncQueue.cc:44
Base Class for a queue of Activities.
Definition: activityQueue.h:21