summaryrefslogtreecommitdiffstats
path: root/include/framework/scheduling/Epoch.h
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2023-10-31 12:41:55 -0400
committerDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2023-10-31 12:41:55 -0400
commit68ae6279476e7d37837ac06474fb558e50ce6706 (patch)
tree98789f86335627e80d295441b79d72a3acbf451b /include/framework/scheduling/Epoch.h
parentca729108869b4143f1eea31f6dde9195decfec9c (diff)
downloaddynamic-extension-68ae6279476e7d37837ac06474fb558e50ce6706.tar.gz
Fixes for various bugs under SerialScheduler
Diffstat (limited to 'include/framework/scheduling/Epoch.h')
-rw-r--r--include/framework/scheduling/Epoch.h31
1 files changed, 26 insertions, 5 deletions
diff --git a/include/framework/scheduling/Epoch.h b/include/framework/scheduling/Epoch.h
index 6bbf927..f4aefe9 100644
--- a/include/framework/scheduling/Epoch.h
+++ b/include/framework/scheduling/Epoch.h
@@ -22,16 +22,20 @@ private:
typedef ExtensionStructure<R, S, Q, L> Structure;
typedef BufferView<R, Q> BufView;
public:
- Epoch()
+ Epoch(size_t number=0)
: m_buffers()
, m_structure(nullptr)
, m_active_jobs(0)
+ , m_active(true)
+ , m_epoch_number(number)
{}
- Epoch(Structure *structure, Buffer *buff)
+ Epoch(size_t number, Structure *structure, Buffer *buff)
: m_buffers()
, m_structure(structure)
, m_active_jobs(0)
+ , m_active(true)
+ , m_epoch_number(number)
{
structure->take_reference();
buff->take_reference();
@@ -62,6 +66,7 @@ public:
}
void end_job() {
+ assert(m_active_jobs.load() > 0);
m_active_jobs.fetch_add(-1);
if (m_active_jobs.load() == 0) {
@@ -74,6 +79,10 @@ public:
return m_active_jobs.load();
}
+ size_t get_epoch_number() {
+ return m_epoch_number;
+ }
+
Structure *get_structure() {
return m_structure;
}
@@ -109,18 +118,29 @@ public:
/*
* Returns a new Epoch object that is a copy of this one. The new object will also contain
- * a copy of the m_structure, rather than a reference to the same one.
+ * a copy of the m_structure, rather than a reference to the same one. The epoch number of
+ * the new epoch will be set to the provided argument.
*/
- Epoch *clone() {
- auto epoch = new Epoch();
+ Epoch *clone(size_t number) {
+ auto epoch = new Epoch(number);
epoch->m_buffers = m_buffers;
if (m_structure) {
epoch->m_structure = m_structure->copy();
+ /* the copy routine returns a structure with 0 references */
+ epoch->m_structure->take_reference();
+ }
+
+ for (auto b : m_buffers) {
+ b->take_reference();
}
return epoch;
}
+ void set_inactive() {
+ m_active = false;
+ }
+
/*
*
*/
@@ -158,5 +178,6 @@ private:
*/
std::atomic<size_t> m_active_jobs;
bool m_active;
+ size_t m_epoch_number;
};
}