Relax restrictions on capacity of buffered_channel#341
Open
eoan-ermine wants to merge 1 commit into
Open
Conversation
…at's not a power of two) There's no reasons for such restriction since 0a6384d. Also implement tests for "capacity is not a power of two" case
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Relaxes the buffered_channel capacity precondition by removing the power-of-two requirement (only capacity >= 2 is now required), and updates the post/dispatch test suites to exercise channels with both power-of-two and non-power-of-two sizes via BOOST_PARAM_TEST_CASE.
Changes:
- Drop the
0 == (capacity & (capacity-1))check frombuffered_channel's constructor and update the documentation accordingly. - Convert most
buffered_channelpost/dispatch tests to parameterized tests that take achannel_sizeargument, run against both{2,3}and{16,17}. - Adapt fill-up/timeout tests to push
channel_size - 1items before expectingfull/timeout.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| include/boost/fiber/buffered_channel.hpp | Loosens the capacity validity check to capacity >= 2. |
| doc/buffered_channel.qbk | Documents the relaxed precondition / error condition. |
| test/test_buffered_channel_post.cpp | Parameterizes tests over channel sizes and updates fill/timeout logic. |
| test/test_buffered_channel_dispatch.cpp | Same parameterization for the dispatch-launch test variant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+67
to
70
| if ( BOOST_UNLIKELY( capacity_ < 2 ) ) { | ||
| throw fiber_error{ std::make_error_code( std::errc::invalid_argument), | ||
| "boost fiber: buffer capacity is invalid" }; | ||
| } |
Comment on lines
+468
to
469
| void test_rangefor(size_t channel_size) { | ||
| boost::fibers::buffered_channel< int > chan{ 2 }; |
Comment on lines
+470
to
471
| void test_rangefor(size_t channel_size) { | ||
| boost::fibers::buffered_channel< int > chan{ 4 }; |
Comment on lines
+501
to
+502
| auto size_2 = { 2, 3 }; | ||
| auto size_16 = { 16, 17 }; |
Comment on lines
+82
to
+87
| void test_try_push_full(size_t channel_size) { | ||
| boost::fibers::buffered_channel< int > c ( channel_size); | ||
| for (int i = 1; i != static_cast<int>( channel_size); ++i) { | ||
| BOOST_CHECK( boost::fibers::channel_op_status::success == c.try_push( i) ); | ||
| } | ||
| BOOST_CHECK( boost::fibers::channel_op_status::full == c.try_push( channel_size) ); |
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.
Relax restrictions on capacity of buffered_channel (allow capacity that's not a power of two)
There's no reasons for such restriction since 0a6384d. Also implement tests for "capacity is not a power of two" case
Closes #329