Skip to content

introduce new CRTP based worker sleep algorithm abstraction

Florian Fischer requested to merge aj46ezos/emper:worker_wakeup_strategy into master

Introduce AbstractWorkerSleepStrategy a CRTP interface class for a worker sleep algorithm. A concrete WorkerSleepStrategy must implement the following functions:

template <CallerEnvironment callerEnvironment>
void notifyMany(unsigned count);

template <CallerEnvironment callerEnvironment>
void notifyOne();

template <CallerEnvironment callerEnvironment>
void notifyAll();

void notifySpecific(workerid_t workerId);

void sleep();

The runtime uses this interface to notify the workers about new work as well as ensuring that all workers get notified on termination.

All sempahore based worker sleep algorithm code was moved from the Runtime into SemaphoreWorkerSleepStrategy which takes the used Semaphore as a template parameter.

This introduces no functional changes and should be an zero-cost abstraction.

Encapsulating the worker sleep algorithm behind an interface allows us to easier experiment with different approaches not based on semaphores ("Wait in the io_uring", "Empty flag per WSQ").

Merge request reports