SST  11.0.0
StructuralSimulationToolkit
syncQueue.h
1 // Copyright 2009-2021 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-2021, 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_SYNCQUEUE_H
13 #define SST_CORE_SYNCQUEUE_H
14 
15 #include <vector>
16 
17 #include "sst/core/activityQueue.h"
18 #include "sst/core/threadsafe.h"
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 public:
31 
32  struct Header {
33  uint32_t mode;
34  uint32_t count;
35  uint32_t buffer_size;
36  };
37 
38  SyncQueue();
39  ~SyncQueue();
40 
41  bool empty() override;
42  int size() override;
43  void insert(Activity* activity) override;
44  Activity* pop() override; // Not a good idea for this particular class
45  Activity* front() override;
46 
47  // Not part of the ActivityQueue interface
48  /** Clear elements from the queue */
49  void clear();
50  /** Accessor method to the internal queue */
51  char* getData();
52 
53  uint64_t getDataSize() {
54  return buf_size + (activities.capacity() * sizeof(Activity*));
55  }
56 
57 private:
58  char* buffer;
59  size_t buf_size;
60  std::vector<Activity*> activities;
61 
63 };
64 
65 
66 } //namespace SST
67 
68 #endif // SST_CORE_SYNCQUEUE_H
Activity * front() override
Returns the next activity.
Definition: syncQueue.cc:69
Activity * pop() override
Remove and return the next activity.
Definition: syncQueue.cc:57
Base class for all Activities in the SST Event Queue.
Definition: activity.h:52
char * getData()
Accessor method to the internal queue.
Definition: syncQueue.cc:83
Definition: syncQueue.h:32
int size() override
Returns the number of activities in the queue.
Definition: syncQueue.cc:43
bool empty() override
Returns true if the queue is empty.
Definition: syncQueue.cc:36
void clear()
Clear elements from the queue.
Definition: syncQueue.cc:76
Definition: threadsafe.h:127
Internal API.
Definition: syncQueue.h:29
void insert(Activity *activity) override
Insert a new activity into the queue.
Definition: syncQueue.cc:50
Base Class for a queue of Activities.
Definition: activityQueue.h:22