diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2025-03-03 13:41:19 -0500 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2025-03-03 13:41:19 -0500 |
| commit | 2ded45f5a20f38fdfd9f348c446c38dc713a5591 (patch) | |
| tree | 746fb09b49ee4c00fc3e4760d899d60d8d8dcce0 /include/framework/scheduling/Task.h | |
| parent | d116b94389538aa8e0e7354fae77693b980de4f0 (diff) | |
| download | dynamic-extension-2ded45f5a20f38fdfd9f348c446c38dc713a5591.tar.gz | |
Fixed a few concurrency bugs
Diffstat (limited to 'include/framework/scheduling/Task.h')
| -rw-r--r-- | include/framework/scheduling/Task.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/include/framework/scheduling/Task.h b/include/framework/scheduling/Task.h index 2d68f56..3dbc9f4 100644 --- a/include/framework/scheduling/Task.h +++ b/include/framework/scheduling/Task.h @@ -1,7 +1,7 @@ /* * include/framework/scheduling/Task.h * - * Copyright (C) 2023-2024 Douglas B. Rumbaugh <drumbaugh@psu.edu> + * Copyright (C) 2023-2025 Douglas B. Rumbaugh <drumbaugh@psu.edu> * * Distributed under the Modified BSD License. * @@ -16,6 +16,7 @@ #include <chrono> #include <functional> #include <future> +#include <condition_variable> #include "framework/scheduling/Version.h" #include "framework/scheduling/statistics.h" @@ -49,9 +50,9 @@ typedef std::function<void(void *)> Job; struct Task { Task(size_t size, size_t ts, Job job, void *args, size_t type = 0, - SchedulerStatistics *stats = nullptr, std::mutex *lk = nullptr) + SchedulerStatistics *stats = nullptr, std::mutex *lk = nullptr, std::condition_variable *cv=nullptr) : m_job(job), m_size(size), m_timestamp(ts), m_args(args), m_type(type), - m_stats(stats), m_lk(lk) {} + m_stats(stats), m_lk(lk), m_cv(cv) {} Job m_job; size_t m_size; @@ -60,6 +61,7 @@ struct Task { size_t m_type; SchedulerStatistics *m_stats; std::mutex *m_lk; + std::condition_variable *m_cv; friend bool operator<(const Task &self, const Task &other) { return self.m_timestamp < other.m_timestamp; @@ -92,6 +94,10 @@ struct Task { if (m_lk) { m_lk->unlock(); } + + if (m_cv) { + m_cv->notify_all(); + } } }; |