Skip to content

Commit 6992576

Browse files
authored
Merge pull request #3833 from embediver/main
Add cancel safety notes to Ticker
2 parents ae5ad91 + ec5f283 commit 6992576

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

embassy-time/src/timer.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ impl Future for Timer {
200200
/// }
201201
/// }
202202
/// ```
203+
///
204+
/// ## Cancel safety
205+
/// It is safe to cancel waiting for the next tick,
206+
/// meaning no tick is lost if the Future is dropped.
203207
pub struct Ticker {
204208
expires_at: Instant,
205209
duration: Duration,
@@ -231,6 +235,9 @@ impl Ticker {
231235
}
232236

233237
/// Waits for the next tick.
238+
///
239+
/// ## Cancel safety
240+
/// The produced Future is cancel safe, meaning no tick is lost if the Future is dropped.
234241
pub fn next(&mut self) -> impl Future<Output = ()> + Send + Sync + '_ {
235242
poll_fn(|cx| {
236243
if self.expires_at <= Instant::now() {

0 commit comments

Comments
 (0)