diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2025-02-11 17:32:10 -0500 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2025-02-11 17:32:10 -0500 |
| commit | 85afe4ef04f327862460570fb0aa4c30afcf7cc7 (patch) | |
| tree | aba55db313b752df4ac073db117900e0128c22fb /include/framework/scheduling/FIFOScheduler.h | |
| parent | c04efb2640421be7a24f851c08e290c89b7b46f2 (diff) | |
| download | dynamic-extension-85afe4ef04f327862460570fb0aa4c30afcf7cc7.tar.gz | |
Progress: began adding parallel merging and locking of levels
Diffstat (limited to 'include/framework/scheduling/FIFOScheduler.h')
| -rw-r--r-- | include/framework/scheduling/FIFOScheduler.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/framework/scheduling/FIFOScheduler.h b/include/framework/scheduling/FIFOScheduler.h index 4c1db8d..8a4cd8d 100644 --- a/include/framework/scheduling/FIFOScheduler.h +++ b/include/framework/scheduling/FIFOScheduler.h @@ -51,13 +51,20 @@ public: m_sched_thrd.join(); m_sched_wakeup_thrd.join(); + m_flush_thread.join(); } void schedule_job(std::function<void(void *)> job, size_t size, void *args, size_t type = 0) { - std::unique_lock<std::mutex> lk(m_cv_lock); + size_t ts = m_counter.fetch_add(1); + if (type == 3) { + do_flush(Task(size, ts, job, args, type, &m_stats, &m_flush_lock)); + return; + } + + std::unique_lock<std::mutex> lk(m_cv_lock); m_stats.job_queued(ts, type, size); m_task_queue.push(Task(size, ts, job, args, type, &m_stats)); @@ -84,6 +91,9 @@ private: std::condition_variable m_cv; std::mutex m_queue_lock; + std::mutex m_flush_lock; + std::thread m_flush_thread; + std::thread m_sched_thrd; std::thread m_sched_wakeup_thrd; ctpl::thread_pool m_thrd_pool; @@ -121,6 +131,14 @@ private: } } while (!m_shutdown.load()); } + + void do_flush(Task task) { + m_flush_lock.lock(); + if (m_flush_thread.joinable()) { + m_flush_thread.join(); + } + m_flush_thread = std::thread(task, 0); + } }; } // namespace de |