pub struct CompletionTracker { /* private fields */ }Expand description
Tracks completion of a single message across all handlers.
§Semantics
The handler_count at send time determines expected. This is “best effort” -
handlers registered concurrently with a send may or may not be counted.
Document explicitly: send awaits approximately the current handler count;
handlers added concurrently may or may not be accounted for.
Implementations§
Source§impl CompletionTracker
impl CompletionTracker
Sourcepub fn new(expected: usize) -> Self
pub fn new(expected: usize) -> Self
Create a new tracker expecting expected handlers to complete.
Note: expected is a snapshot at send time. Handlers registered
concurrently may not be included in this count.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if all handlers have completed.
Sourcepub fn complete_one(&self)
pub fn complete_one(&self)
Signal successful completion of one handler.
Calling this more than once per handler is a logic error but is handled gracefully (extra completions are ignored after the expected count is reached).
Sourcepub fn fail(&self, error: RelayError)
pub fn fail(&self, error: RelayError)
Signal failure with an error.
Sourcepub fn take_error(&self) -> Option<RelayError>
pub fn take_error(&self) -> Option<RelayError>
Take the error if one occurred.
Sourcepub fn wait(&self) -> CompletionFuture<'_>
pub fn wait(&self) -> CompletionFuture<'_>
Returns a future that completes when all handlers have finished.
This is the proper way to await completion - it’s a pollable future that doesn’t spawn tasks from within poll().
Sourcepub async fn wait_async(&self)
pub async fn wait_async(&self)
Async method to wait for completion.
Alternative to wait() for use in async contexts where you want to
await directly.
Source§impl CompletionTracker
impl CompletionTracker
Sourcepub async fn wait_owned(self: Arc<Self>)
pub async fn wait_owned(self: Arc<Self>)
Returns an owned future that completes when all handlers have finished.
This version takes Arc<Self> and returns a 'static future that can
be stored in a state machine.