From 2ded45f5a20f38fdfd9f348c446c38dc713a5591 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 3 Mar 2025 13:41:19 -0500 Subject: Fixed a few concurrency bugs --- include/framework/scheduling/Task.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'include/framework/scheduling/Task.h') 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 + * Copyright (C) 2023-2025 Douglas B. Rumbaugh * * Distributed under the Modified BSD License. * @@ -16,6 +16,7 @@ #include #include #include +#include #include "framework/scheduling/Version.h" #include "framework/scheduling/statistics.h" @@ -49,9 +50,9 @@ typedef std::function 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(); + } } }; -- cgit v1.2.3