seastar
seastar copied to clipboard
condition_variable: add support for abort source
Add an optional abort_source* parameter to wait functions so individual waiters can be aborted using an abort source.
Add respective unit tests.
CI failures look unrelated
condition_variable can stop on an arbitrary condition. You should be able to write
auto abort_me = as.subscribe([&] { cv.broadcast(); });
...
co_await cv.when([&] { return as.abort_requested() || other_conditions; });
condition_variable can stop on an arbitrary condition. You should be able to write
auto abort_me = as.subscribe([&] { cv.broadcast(); }); ... co_await cv.when([&] { return as.abort_requested() || other_conditions; });
That's true, but this way puts a larger burden on the caller.
For example, the cv wait function is effectively noexcept so it will require more logic to check the condition again outside when
to distinguish between the abort and normal operation mode cases.
That said, orthogonal to this PR, we can catch exceptions from the predicate function and propagate them to the awaiter.
In any case, while we're debating this PR, I can send a preliminary PR with the first patch, and bits from the 3rd patch (like checking _ex
in {awaiter,predicate_awaiter}::await_ready
)
condition_variable can stop on an arbitrary condition. You should be able to write
auto abort_me = as.subscribe([&] { cv.broadcast(); }); ... co_await cv.when([&] { return as.abort_requested() || other_conditions; });
That's true, but this way puts a larger burden on the caller. For example, the cv wait function is effectively noexcept so it will require more logic to check the condition again outside
when
to distinguish between the abort and normal operation mode cases. That said, orthogonal to this PR, we can catch exceptions from the predicate function and propagate them to the awaiter.In any case, while we're debating this PR, I can send a preliminary PR with the first patch, and bits from the 3rd patch (like checking
_ex
in{awaiter,predicate_awaiter}::await_ready
)
It turns a very low-level API like condition variable depend on a higher level API like abort_source.
We could turn it around and say that abort_source is a low-level API, but that's not how I view it.