Remove all timed-wait APIs#2
Open
Akatsukis wants to merge 15 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These mutex types are unused by the top-level project. Removes source files, headers, and references from CMakeLists.txt and all.hpp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes source, header, examples, and performance benchmarks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes source, header, examples, and performance benchmarks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes header, example, and include references from fiber.hpp and all.hpp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes source, header, dedicated test files, and dead do_wait() references in fiber tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes fss.hpp, detail/fss.hpp, test files, and cleans fss_data_ from context.hpp and context.cpp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes header, test files, and examples that solely used unbuffered_channel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes rtm.hpp, spinlock_rtm.hpp, and strips BOOST_USE_TSX branches from spinlock.hpp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR removes all timed-wait functionality from Boost.Fiber’s public APIs and internal scheduler machinery, eliminating the sleep-queue and associated deadline scanning to better support fiber pools that rely exclusively on untimed waits plus explicit wakeups.
Changes:
- Removed timed-wait APIs across
this_fiber,condition_variable(_any),future/shared_future, andbuffered_channel. - Deleted scheduler sleep-queue support (
sleep_queue_,sleep2ready_(),context::{tp_,sleep_*}) and switched the dispatcher to untimedalgorithm::suspend(). - Renamed the scheduling-algorithm hook from
suspend_until(time_point)tosuspend()and updatedround_robinaccordingly.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/waker.cpp | Removes timed suspension helper from wait_queue. |
| src/scheduler.cpp | Deletes sleep-queue logic and switches idle waiting to untimed suspend. |
| src/context.cpp | Removes timed-wait forwarding APIs and sleep-link helpers. |
| src/algo/round_robin.cpp | Replaces timed suspend implementation with untimed suspend(). |
| include/boost/fiber/waker.hpp | Removes timed-wait declaration from wait_queue. |
| include/boost/fiber/scheduler.hpp | Removes sleep-queue types/members and timed wait_until APIs. |
| include/boost/fiber/operations.hpp | Removes this_fiber::sleep_for/sleep_until APIs. |
| include/boost/fiber/future/future.hpp | Removes future/shared_future timed wait APIs. |
| include/boost/fiber/future/detail/shared_state.hpp | Removes shared-state timed wait helpers. |
| include/boost/fiber/context.hpp | Removes sleep-hook members and timed-wait declarations. |
| include/boost/fiber/condition_variable.hpp | Removes condition_variable(_any) timed wait APIs. |
| include/boost/fiber/buffered_channel.hpp | Removes timed push/pop channel operations. |
| include/boost/fiber/algo/round_robin.hpp | Updates algorithm interface override to suspend(). |
| include/boost/fiber/algo/algorithm.hpp | Replaces suspend_until() with suspend() in the base interface. |
Comments suppressed due to low confidence (2)
include/boost/fiber/operations.hpp:52
- This header removes
boost::this_fiber::sleep_for()/sleep_until(), but the repo still calls these APIs in both examples and tests (e.g.examples/wait_stuff.cpp,test/test_fiber_*.cpp,test/test_future_*.cpp,test/test_mutex_*.cpp). As-is, those targets will no longer compile. Update the examples/tests to use the remaining untimed primitives (e.g. condition variables + explicit wakeups, barriers/latches, or yields) or remove/disable the affected tests if they are no longer meaningful without timed waits.
inline
fibers::fiber::id get_id() noexcept {
return fibers::context::active()->get_id();
}
inline
void yield() noexcept {
fibers::context::active()->yield();
}
template< typename PROPS >
PROPS & properties() {
fibers::fiber_properties * props = fibers::context::active()->get_properties();
if ( BOOST_LIKELY( nullptr == props) ) {
// props could be nullptr if the thread's main fiber has not yet
// yielded (not yet passed through algorithm_with_properties::
// awakened()). Address that by yielding right now.
yield();
// Try again to obtain the fiber_properties subclass instance ptr.
// Walk through the whole chain again because who knows WHAT might
// have happened while we were yielding!
props = fibers::context::active()->get_properties();
// Could still be hosed if the running manager isn't a subclass of
// algorithm_with_properties.
BOOST_ASSERT_MSG( props, "this_fiber::properties not set");
}
return dynamic_cast< PROPS & >( * props );
}
include/boost/fiber/buffered_channel.hpp:188
- The timed buffered_channel operations (
push_wait_for/push_wait_until/pop_wait_for/pop_wait_until) are removed, but the tests still call them (e.g.test/test_buffered_channel_*.cpp). This will break test builds. Update those tests to cover the remaining APIs (push,try_push,pop,try_pop, close semantics) or delete the timeout-specific test cases since the timeout feature is being removed.
waiting_consumers_.notify_one();
return channel_op_status::success;
}
channel_op_status push( value_type const& value) {
context * active_ctx = context::active();
for (;;) {
detail::spinlock_lock lk{ splk_ };
if ( BOOST_UNLIKELY( is_closed_() ) ) {
return channel_op_status::closed;
}
if ( is_full_() ) {
waiting_producers_.suspend_and_wait( lk, active_ctx);
} else {
slots_[pidx_] = value;
pidx_ = (pidx_ + 1) % capacity_;
waiting_consumers_.notify_one();
return channel_op_status::success;
}
}
}
channel_op_status push( value_type && value) {
context * active_ctx = context::active();
for (;;) {
detail::spinlock_lock lk{ splk_ };
if ( BOOST_UNLIKELY( is_closed_() ) ) {
return channel_op_status::closed;
}
if ( is_full_() ) {
waiting_producers_.suspend_and_wait( lk, active_ctx);
} else {
slots_[pidx_] = std::move( value);
pidx_ = (pidx_ + 1) % capacity_;
waiting_consumers_.notify_one();
return channel_op_status::success;
}
}
}
channel_op_status try_pop( value_type & value) {
detail::spinlock_lock lk{ splk_ };
if ( is_empty_() ) {
return is_closed_()
? channel_op_status::closed
: channel_op_status::empty;
}
value = std::move( slots_[cidx_]);
cidx_ = (cidx_ + 1) % capacity_;
waiting_producers_.notify_one();
return channel_op_status::success;
}
channel_op_status pop( value_type & value) {
context * active_ctx = context::active();
for (;;) {
detail::spinlock_lock lk{ splk_ };
if ( is_empty_() ) {
if ( BOOST_UNLIKELY( is_closed_() ) ) {
return channel_op_status::closed;
}
waiting_consumers_.suspend_and_wait( lk, active_ctx);
} else {
value = std::move( slots_[cidx_]);
cidx_ = (cidx_ + 1) % capacity_;
waiting_producers_.notify_one();
return channel_op_status::success;
}
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6e8cc6f to
9e51552
Compare
Removes the sleep queue from the scheduler (sleep2ready_, wait_until, sleep_hook, sleep_waker_, tp_), and all timed-wait variants from condition_variable, buffered_channel, future, and operations.hpp. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Drops all timed-wait APIs from boost.fiber. Affected interfaces:
- boost::this_fiber::sleep_for / sleep_until
- condition_variable::wait_for / wait_until (both _any and the
mutex-bound variants)
- future<T>::wait_for / wait_until, shared_future<T>::wait_for / wait_until
- buffered_channel::push_wait_for / push_wait_until /
pop_wait_for / pop_wait_until
- context::wait_until, context::sleep_link / sleep_unlink /
sleep_is_linked, plus the sleep_hook_, sleep_waker_, tp_ members
- scheduler::wait_until, scheduler::sleep2ready_, sleep_queue_
- wait_queue::suspend_and_wait_until
algorithm::suspend_until(time_point) is renamed to algorithm::suspend()
since the time_point has no meaning without a sleep queue.
round_robin::suspend uses condition_variable::wait(lk, pred) instead of
the timed variant.
Also removes upstream tests and examples that exercised the removed
APIs and would no longer build:
- examples/priority.cpp, examples/wait_stuff.cpp
- test/test_buffered_channel_{dispatch,post}.cpp
- test/test_condition_variable_{,any_}{dispatch,post}.cpp
- test/test_fiber_{dispatch,post}.cpp
- test/test_future_{dispatch,post}.cpp
- test/test_mutex_{dispatch,post}.cpp
- test/test_shared_future_{dispatch,post}.cpp
The corresponding stanzas are stripped from examples/Jamfile.v2 and
test/Jamfile.v2. Untimed coverage of mutex/future/channel/fiber
behaviour remains in the MT variants (test_mutex_mt_*.cpp,
test_future_mt_*.cpp) and the unmodified barrier/promise/async/
packaged_task suites.
Intended for fiber pools where all synchronization is via untimed
waits + cross-thread wakeups; the sleep-queue scan in every dispatch
iteration is gone.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9e51552 to
597016c
Compare
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.
Drops all timed-wait APIs from boost.fiber. Affected interfaces:
algorithm::suspend_until(time_point) is renamed to algorithm::suspend() since the time_point has no meaning without a sleep queue. round_robin::suspend uses condition_variable::wait(lk, pred) instead of the timed variant.
Intended for fiber pools where all synchronization is via untimed waits + cross-thread wakeups; the sleep-queue scan in every dispatch iteration is gone.