Add FiberConditionVariable synchronization primitive#50
Closed
mstetsyuk wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a fiber-aware condition variable primitive to the silk::fibers synchronization toolkit, intended to support fiber-enabled usage in higher-level components (e.g., PoolBase).
Changes:
- Introduces
silk::FiberConditionVariablewithwait()andwait_for()APIs that release/reacquire an external lock around the wait. - Implements notification via an internal
FiberSequencer, including a timed wait path that cancels on timeout.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| #include <silk/fibers/future.h> | ||
| #include <silk/fibers/sequencer.h> | ||
|
|
Comment on lines
+60
to
+64
| /** Wake every waiter whose captured token has been reached. */ | ||
| void notify_one() noexcept { (void)sequencer.increment(); } | ||
|
|
||
| /** Wake every waiter whose captured token has been reached. */ | ||
| void notify_all() noexcept { (void)sequencer.increment(); } |
Comment on lines
+39
to
+41
| template <typename Lock> | ||
| [[nodiscard]] int wait_for(Lock & lock, uint64_t nanoseconds) noexcept | ||
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
As part of ClickHouse/ClickHouse#101833, we're going to need to make
PoolBasesupport Silk fibers, including condition variables.