Skip to content

Commit 4ebadca

Browse files
authored
docs(stack/gate): note Tx::lost() cancel safety (#4482)
cancel safety is a relevant quality of `Future`s returned by `async` functions. this affects whether a future is safe to use within a `tokio::select!` block. this function is used in some of these macro invocations, like the `ConsecutiveFailures` circuit-breaker. this function is cancel safe because it is strictly delegating down to `tokio::sync::watch::Sender::closed()`, which is itself cancel safe: <https://docs.rs/tokio/latest/tokio/sync/watch/struct.Sender.html#method.closed>. Signed-off-by: katelyn martin <kate@buoyant.io>
1 parent 3aa8923 commit 4ebadca

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

linkerd/stack/src/gate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ impl Rx {
120120

121121
impl Tx {
122122
/// Returns when all associated `Rx` clones are dropped.
123+
///
124+
/// # Cancel safety
125+
///
126+
/// This method is cancel safe.
123127
pub async fn lost(&self) {
124128
self.0.closed().await
125129
}

0 commit comments

Comments
 (0)