Skip to content

Instantly share code, notes, and snippets.

@luser
Created April 29, 2020 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luser/139722e44f5ddb0bcb4dd3c4a649ddba to your computer and use it in GitHub Desktop.
Save luser/139722e44f5ddb0bcb4dd3c4a649ddba to your computer and use it in GitHub Desktop.
idle_timeout_reset
/// Create a `Future` that will resolve after `idle_period` has elapsed, along with an `IdleReset` that can be used to reset the time period or cancel the timeout.
///
/// This can be used to trigger an event that should happen after a period of inactivity. Activity in this situation is indicated by calling
/// `idle_reset` on the returned `IdleReset`. The timeout can be cancelled by calling `cancel` on the `IdleReset`.
///
/// Returns a tuple of (`IdleReset`, `Future`)
pub fn idle_timeout_reset(
idle_period: Duration,
) -> (IdleReset, impl Future<Output = bool> + Send + 'static) {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment