Skip to content

Add FiberConditionVariable synchronization primitive - #50

Closed
mstetsyuk wants to merge 1 commit into
mainfrom
condition-variable
Closed

mstetsyuk wants to merge 1 commit into
mainfrom
condition-variable

Conversation

@mstetsyuk

Copy link
Copy Markdown
Member

Why

As part of ClickHouse/ClickHouse#101833, we're going to need to make PoolBase support Silk fibers, including condition variables.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::FiberConditionVariable with wait() and wait_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
{
@mstetsyuk mstetsyuk closed this May 27, 2026
@vadimskipin
vadimskipin deleted the condition-variable branch August 22, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants