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

Improve EMPER worker wakeup strategy option

Initiailze the WORKER_WAKEUP_STRATEGY via the contents of the
EMPER_WORKER_WAKEUP_STRATEGY macro. This makes it easier to add
additional strategies later on.
parent 5cb3e00e
No related branches found
No related tags found
No related merge requests found
...@@ -23,14 +23,14 @@ static const bool WORKER_SLEEP = ...@@ -23,14 +23,14 @@ static const bool WORKER_SLEEP =
false false
#endif #endif
; ;
enum class WorkerWakeupStrategy { one, all };
enum class WorkerWakeupStrategy {
one,
all,
};
static const enum WorkerWakeupStrategy WORKER_WAKEUP_STRATEGY = static const enum WorkerWakeupStrategy WORKER_WAKEUP_STRATEGY =
#ifdef EMPER_WORKER_WAKEUP_ALL WorkerWakeupStrategy::EMPER_WORKER_WAKEUP_STRATEGY;
WorkerWakeupStrategy::all
#else
WorkerWakeupStrategy::one
#endif
;
static const bool LIBURCU = static const bool LIBURCU =
#ifdef EMPER_LIBURCU #ifdef EMPER_LIBURCU
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include <atomic> // for atomic, memory_order_relaxed #include <atomic> // for atomic, memory_order_relaxed
#include <cassert> // for assert #include <cassert> // for assert
#include <condition_variable> // for condition_variable #include <condition_variable> // for condition_variable
#include <cstddef> // for size_t
#include <cstdint> // for intptr_t #include <cstdint> // for intptr_t
#include <cstdlib> // for abort
#include <functional> // for function #include <functional> // for function
#include <mutex> // for mutex, lock_guard, unique_lock #include <mutex> // for mutex, lock_guard, unique_lock
#include <random> #include <random>
...@@ -90,9 +90,12 @@ class Runtime : public Logger<LogSubsystem::RUNTI> { ...@@ -90,9 +90,12 @@ class Runtime : public Logger<LogSubsystem::RUNTI> {
if constexpr (emper::WORKER_WAKEUP_STRATEGY == emper::WorkerWakeupStrategy::all) { if constexpr (emper::WORKER_WAKEUP_STRATEGY == emper::WorkerWakeupStrategy::all) {
sleepingWorkers.store(0, std::memory_order_relaxed); sleepingWorkers.store(0, std::memory_order_relaxed);
workerSleepConditionVariable.notify_all(); workerSleepConditionVariable.notify_all();
} else { } else if (emper::WORKER_WAKEUP_STRATEGY == emper::WorkerWakeupStrategy::one) {
sleepingWorkers.fetch_sub(1, std::memory_order_relaxed); sleepingWorkers.fetch_sub(1, std::memory_order_relaxed);
workerSleepConditionVariable.notify_one(); workerSleepConditionVariable.notify_one();
} else {
// Unknown worker wakeup strategy.
abort();
} }
} }
......
...@@ -26,7 +26,7 @@ if option_urcu ...@@ -26,7 +26,7 @@ if option_urcu
endif endif
conf_data.set('EMPER_WORKER_SLEEP', get_option('worker_sleep')) conf_data.set('EMPER_WORKER_SLEEP', get_option('worker_sleep'))
conf_data.set('EMPER_WORKER_WAKEUP_ALL', get_option('worker_wakeup_strategy') == 'all') conf_data.set('EMPER_WORKER_WAKEUP_STRATEGY', get_option('worker_wakeup_strategy'))
conf_data.set('EMPER_LOCKED_WS_QUEUE', get_option('locked_ws_queue')) conf_data.set('EMPER_LOCKED_WS_QUEUE', get_option('locked_ws_queue'))
conf_data.set('EMPER_OVERFLOW_QUEUE', get_option('overflow_queue')) conf_data.set('EMPER_OVERFLOW_QUEUE', get_option('overflow_queue'))
conf_data.set('EMPER_LOCKED_MPSC_QUEUE', get_option('locked_mpsc_queue')) conf_data.set('EMPER_LOCKED_MPSC_QUEUE', get_option('locked_mpsc_queue'))
......
...@@ -19,7 +19,7 @@ option( ...@@ -19,7 +19,7 @@ option(
option( option(
'worker_wakeup_strategy', 'worker_wakeup_strategy',
type: 'combo', type: 'combo',
description: 'How many workers should be signaled onNewWork', description: 'The strategy used to wakeup sleeping workers (only effective if worker_sleep is enabled)',
choices: ['one', 'all'], choices: ['one', 'all'],
value: 'one', value: 'one',
) )
......
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