SST  7.0.0
StructuralSimulationToolkit
syncQueue.h
1 // Copyright 2009-2017 Sandia Corporation. Under the terms
2 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2017, Sandia Corporation
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 <sst/core/serialization.h>
16 
17 #include <vector>
18 
19 #include <sst/core/activityQueue.h>
20 #include <sst/core/threadsafe.h>
21 
22 namespace SST {
23 
24 /**
25  * \class SyncQueue
26  *
27  * Internal API
28  *
29  * Activity Queue for use by Sync Objects
30  */
31 class SyncQueue : public ActivityQueue {
32 public:
33 
34  struct Header {
35  uint32_t mode;
36  uint32_t count;
37  uint32_t buffer_size;
38  };
39 
40  SyncQueue();
41  ~SyncQueue();
42 
43  bool empty() override;
44  int size() override;
45  void insert(Activity* activity) override;
46  Activity* pop() override; // Not a good idea for this particular class
47  Activity* front() override;
48 
49  // Not part of the ActivityQueue interface
50  /** Clear elements from the queue */
51  void clear();
52  /** Accessor method to the internal queue */
53  char* getData();
54 
55  uint64_t getDataSize() {
56  return buf_size + (activities.capacity() * sizeof(Activity*));
57  }
58 
59 private:
60  char* buffer;
61  size_t buf_size;
62  std::vector<Activity*> activities;
63 
65 };
66 
67 
68 } //namespace SST
69 
70 #endif // SST_CORE_SYNCQUEUE_H
Activity * front() override
Returns the next activity.
Definition: syncQueue.cc:70
Activity * pop() override
Remove and return the next activity.
Definition: syncQueue.cc:58
Base class for all Activities in the SST Event Queue.
Definition: activity.h:54
char * getData()
Accessor method to the internal queue.
Definition: syncQueue.cc:84
Definition: syncQueue.h:34
Definition: action.cc:17
int size() override
Returns the number of activities in the queue.
Definition: syncQueue.cc:44
bool empty() override
Returns true if the queue is empty.
Definition: syncQueue.cc:37
void clear()
Clear elements from the queue.
Definition: syncQueue.cc:77
Definition: threadsafe.h:116
Internal API.
Definition: syncQueue.h:31
void insert(Activity *activity) override
Insert a new activity into the queue.
Definition: syncQueue.cc:51
Base Class for a queue of Activities.
Definition: activityQueue.h:22