Skip to navigation

holoscan::channel_internal::wait_and_receive_next

Beta
View as Markdown
template <typename Receive>
std::invoke_result_t<Receive &> holoscan::channel_internal::wait_and_receive_next(
WaitSetSubscriber &subscriber,
const std::chrono::steady_clock::time_point deadline,
const std::stop_token *const stop_token,
Receive receive
)

Receive one sample from subscriber, waiting for readiness until deadline.

The first attempt runs before any wait context exists, so an already queued sample is returned without building a wait set and without a kernel wait. ErrorCode::kNotReady is absorbed from both the attempt and the wait, because readiness is only a hint: an attempt that loses its race against a lossy replacement, a private control operation, or a competing consumer waits again against the same absolute deadline. Every other error is returned unchanged from the first attempt that produces it, so a terminal ErrorCode::kClosed or an active-loan ErrorCode::kFailure is reported before any wait is built.

This function never returns ErrorCode::kNotReady. A subscriber that keeps reporting readiness while every attempt loses its race retries at full speed until deadline, which is checked after every readiness query on both its outcomes; that absolute deadline is the only bound, which is why no duration overload exists.

Returns: The receive result, or the first error that is not ErrorCode::kNotReady.

Template parameters

Receive
typename

Callable taking no arguments and returning this endpoint family’s expected receive result.

Parameters

subscriber
WaitSetSubscriber &

Endpoint whose readiness is awaited; it must outlive this call.

deadline
const std::chrono::steady_clock::time_point

Steady-clock coordinate after which the wait reports a timeout.

stop_token
const std::stop_token *const

Optional borrowed cancellation observer; null disables cancellation.

receive
Receive

One repeatable receive attempt, invoked at least once.