Ensure context canceller takes a reference

This commit is contained in:
Tobie Morgan Hitchcock 2022-01-21 12:51:05 +00:00
parent 3ffd194a05
commit adff751a7e

View file

@ -1,6 +1,7 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
#[derive(Default)]
pub struct Canceller {
/// A reference to the canceled value of a context.
cancelled: Arc<AtomicBool>,
@ -14,7 +15,7 @@ impl Canceller {
}
}
// Cancel the context.
pub fn cancel(self) {
pub fn cancel(&self) {
self.cancelled.store(true, Ordering::SeqCst);
}
}