Commit f133174a authored by Florian Fischer's avatar Florian Fischer
Browse files

[IoContext] introduce waitfree io stealing

Waitfree IO-stealing can be enabled with the meson option
-Dio_waitfree_stealing.
parent 5c7e3e9b
......@@ -167,6 +167,14 @@ static const bool IO_URING_SQPOLL =
#endif
;
static const bool WAITFREE_IO_STEALING =
#ifdef EMPER_IO_WAITFREE_STEALING
true
#else
false
#endif
;
// Initialize this bool in Emper.cpp because it needs code evaluation
// (LinuxVersion::compare) during runtime.
// Using a static variable here means EACH object file including this header has to
......
......@@ -440,6 +440,13 @@ class IoContext : public Logger<LogSubsystem::IO> {
template <CallerEnvironment callerEnvironment>
[[nodiscard]] auto reapSingleCompletion() -> Fiber * {
Fiber *fiber;
if constexpr (emper::WAITFREE_IO_STEALING) {
auto res = tryReapCompletionWaitFree<callerEnvironment>(&fiber);
if (res == emper::StealingResult::Stolen) return fiber;
return nullptr;
}
return reapCompletions<callerEnvironment, 1>(&fiber) == 1 ? fiber : nullptr;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment