Skip to content
Snippets Groups Projects
Commit b4bcdaa2 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Move dispatchLoopSleep from Runtime into Dispatcher

parent 80188cf9
No related branches found
No related tags found
1 merge request!358Add worker sleep stats, rework stats machinery
......@@ -15,8 +15,25 @@ void Dispatcher::dispatchLoopDoSleep() {
runtime.maybeTerminateWorker();
if constexpr (emper::WORKER_SLEEP) {
runtime.dispatchLoopSleep();
dispatchLoopSleep();
} else {
sched_yield();
}
}
void Dispatcher::dispatchLoopSleep() {
auto& wakeupStrategy = runtime.wakeupStrategy;
auto& workerSleepStrategy = runtime.workerSleepStrategy;
auto& terminateWorkers = runtime.terminateWorkers;
bool canWake;
do {
// Notify the wakeup strategy about our sleep attempt
if (!wakeupStrategy.canSleep()) break;
workerSleepStrategy.sleep();
// We always wakeup if the runtime is terminating
canWake = wakeupStrategy.canWakeup() || terminateWorkers.load(std::memory_order_relaxed);
} while (!canWake);
}
......@@ -13,6 +13,9 @@ class Runtime;
class ContextManager;
class Dispatcher : public Logger<LogSubsystem::DISP> {
private:
void dispatchLoopSleep();
protected:
Runtime& runtime;
......
......@@ -166,19 +166,6 @@ class Runtime : public Logger<LogSubsystem::RUNTI> {
void maybeTerminateWorker();
void dispatchLoopSleep() {
bool canWake;
do {
// Notify the wakeup strategy about our sleep attempt
if (!wakeupStrategy.canSleep()) break;
workerSleepStrategy.sleep();
// We always wakeup if the runtime is terminating
canWake = wakeupStrategy.canWakeup() || terminateWorkers.load(std::memory_order_relaxed);
} while (!canWake);
}
auto nextFiber() -> std::optional<NextFiberResult>;
public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment