summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/framework/scheduling/FIFOScheduler.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/include/framework/scheduling/FIFOScheduler.h b/include/framework/scheduling/FIFOScheduler.h
index 513a3a2..b77a8a1 100644
--- a/include/framework/scheduling/FIFOScheduler.h
+++ b/include/framework/scheduling/FIFOScheduler.h
@@ -10,7 +10,7 @@
#include <thread>
#include <condition_variable>
-
+#include <chrono>
#include "framework/scheduling/Task.h"
#include "framework/scheduling/statistics.h"
@@ -19,6 +19,8 @@
namespace de {
+using namespace std::literals::chrono_literals;
+
class FIFOScheduler {
private:
@@ -33,6 +35,7 @@ public:
, m_shutdown(false)
{
m_sched_thrd = std::thread(&FIFOScheduler::run, this);
+ m_sched_wakeup_thrd = std::thread(&FIFOScheduler::periodic_wakeup, this);
m_thrd_pool.resize(m_thrd_cnt);
}
@@ -77,6 +80,7 @@ private:
std::condition_variable m_cv;
std::thread m_sched_thrd;
+ std::thread m_sched_wakeup_thrd;
ctpl::thread_pool m_thrd_pool;
std::atomic<size_t> m_used_thrds;
@@ -84,6 +88,13 @@ private:
SchedulerStatistics m_stats;
+ void periodic_wakeup() {
+ do {
+ std::this_thread::sleep_for(10us);
+ m_cv.notify_all();
+ } while (!m_shutdown.load());
+ }
+
void schedule_next() {
assert(m_task_queue.size() > 0);
auto t = m_task_queue.pop();