Skip to content

Commit f2f0f5f

Browse files
committed
add mux capacity() methods
1 parent b86af81 commit f2f0f5f

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

include/tmc/mux_many.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,11 @@ class mux_many : private tmc::detail::AwaitTagNoGroupCoAwaitLvalue {
333333

334334
/// Provides a sentinel value that can be compared against the value returned
335335
/// from co_await.
336-
inline size_t end() noexcept { return 64; }
336+
inline constexpr size_t end() const noexcept { return 64; }
337+
338+
/// Returns the capacity of the mux, equal to the `Count` template argument.
339+
/// This is the maximum number of awaitables that may be active concurrently.
340+
inline constexpr size_t capacity() const noexcept { return Count; }
337341

338342
/// Gets the ready result at the given index.
339343
TMC_TSAN_NO_SPECULATE inline std::add_lvalue_reference_t<Result>

include/tmc/mux_tuple.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ class mux_tuple : private tmc::detail::AwaitTagNoGroupCoAwaitLvalue {
224224

225225
/// Provides a sentinel value that can be compared against the value returned
226226
/// from co_await.
227-
inline size_t end() noexcept { return 64; }
227+
inline constexpr size_t end() const noexcept { return 64; }
228+
229+
/// Returns the capacity of the mux, equal to the number of `Result` template arguments.
230+
/// This is the maximum number of awaitables that may be active concurrently.
231+
inline constexpr size_t capacity() const noexcept { return Count; }
228232

229233
/// Gets the ready result at the given index.
230234
template <size_t I>

include/tmc/select.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ template <typename Awaitable, typename Canceller> consteval bool canceller_is_as
6464
/// an awaitable (an async cancel, which `select()` awaits). The canceller is
6565
/// stored by value and invoked only for losers, so an awaitable-returning canceller
6666
/// builds its awaitable only when the cancel is actually needed. Therefore, it is safe to
67-
/// pass a capturing coroutine lambda here it will be stored by value and outlive the
67+
/// pass a capturing coroutine lambda here - it will be stored by value and outlive the
6868
/// awaited invocation.
6969
/// ```
7070
/// // sync cancel
@@ -130,7 +130,7 @@ template <typename Awaitable, typename Canceller> class cancellable {
130130
///
131131
/// The canceller is stored by value and invoked only for losers, so an
132132
/// awaitable-returning canceller builds its awaitable only when the cancel is actually
133-
/// needed. Therefore, it is safe to pass a capturing coroutine lambda here it will be
133+
/// needed. Therefore, it is safe to pass a capturing coroutine lambda here - it will be
134134
/// stored by value and outlive the awaited invocation.
135135
/// ```
136136
/// // sync cancel

0 commit comments

Comments
 (0)