SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: Apache-2.0
template<std::ranges::range Range>
| auto rapidsmpf::streaming::coro_results |
( |
Range && |
task_results | ) |
|
Collect the results of multiple finished coroutines.
This helper consumes a range of coroutine result objects (e.g., from coro::when_all or coro::when_any) and extracts their return values by invoking .return_value() on each element.
- If the tasks produce a non-void type
T, all values are collected into a std::vector<T> and returned.
- If the tasks return
void, the function simply invokes .return_value() on each element to surface any unhandled exceptions and then returns void.
- Template Parameters
-
| Range | A range type whose elements support a .return_value() member function. Typically the result of functions and coroutines like coro::when_all and coro::wait_all |
- Parameters
-
| task_results | A range of completed coroutine results. |
- Returns
std::vector<T> if the underlying tasks return a value of type T or void if the underlying tasks return void.
- Note
- All result types must be the same. If your coroutines produce heterogeneous result types, this helper cannot be used; you must instead extract each result manually by calling
.return_value() on each element, or use the tuple form of coro_results.
-
The return values of libcoro's gather functions such as
coro::when_all and coro::wait_all must always be retrieved by calling .return_value() (either directly or via this helper). Failing to do so leaves exceptions unobserved, which can cause the streaming pipeline to deadlock or hang indefinitely while waiting for error propagation.
Definition at line 48 of file coro_utils.hpp.
template<typename... Args>
| auto rapidsmpf::streaming::coro_results |
( |
std::tuple< Args... > && |
results | ) |
|
Collect the results of multiple finished coroutines from a tuple.
This overload works with a tuple of coroutine result objects, typically from co_await coro::when_all(...).
- If the tasks produce non-void types, all values are collected into a
std::tuple<T1, T2, ...> and returned.
- If the tasks return
void, the function simply invokes .return_value() on each element to surface any unhandled exceptions and then returns void.
- Template Parameters
-
| Args | Types of coroutine result objects in the tuple |
- Parameters
-
| results | Tuple of coroutine result objects to extract values from |
- Returns
std::tuple<T1, T2, ...> if the underlying tasks return values, or void if all underlying tasks return void.
Definition at line 87 of file coro_utils.hpp.
Reserve memory using the context memory reservation mechanism.
Submits a memory reservation request for the configured memory type and suspends until the request is satisfied. If no pending reservation request can be satisfied within the configured "memory_reserve_timeout", the behavior depends on allow_overbooking.
This is a convenience helper that returns only the MemoryReservation. If more control is required, for example inspecting the amount of overbooking, callers should use MemoryReserveOrWait directly, such as ctx.memory(MemoryType::DEVICE).reserve_or_wait_or_overbook(size, net_memory_delta).
Priority and progress semantics are identical to MemoryReserveOrWait::reserve_or_wait(). In particular, net_memory_delta is used as a heuristic to prefer eligible requests that are expected to reduce memory pressure sooner. Smaller values have higher priority.
- Parameters
-
| ctx | Actor context used to obtain the memory reservation handle. |
| size | Number of bytes to reserve. |
| net_memory_delta | Estimated net change in memory usage after the reservation is allocated and the dependent operation completes. Smaller values have higher priority. |
| mem_type | Memory type for which to reserve memory. |
| allow_overbooking | Controls the behavior when no progress is possible within the configured timeout:
- If set to
AllowOverbooking::YES, the call may overbook memory when forcing progress.
- If set to
AllowOverbooking::NO, the call fails if no progress is possible.
- If not provided, the default behavior is determined by the configuration option
"allow_overbooking_by_default".
|
- Returns
- The allocated memory reservation.
- Exceptions
-
ctx,
1024,
0,
);
EXPECT_EQ(res.size(), 1024);
ctx,
2048,
0,
);
coro::task< MemoryReservation > reserve_memory(std::shared_ptr< Context > ctx, std::size_t size, std::int64_t net_memory_delta, MemoryType mem_type=MemoryType::DEVICE, std::optional< AllowOverbooking > allow_overbooking=std::nullopt)
Reserve memory using the context memory reservation mechanism.
@ YES
Overbooking is allowed.
@ NO
Overbooking is not allowed.
- See also
- MemoryReserveOrWait::reserve_or_wait()
-
MemoryReserveOrWait::reserve_or_wait_or_overbook()
-
MemoryReserveOrWait::reserve_or_wait_or_fail()