Rename timeout_at to with_deadline

This commit is contained in:
Caleb Jamison 2024-01-31 16:26:11 -05:00
parent 1e698af05b
commit 8b7d856195
3 changed files with 5 additions and 5 deletions

View file

@ -32,7 +32,7 @@ pub use delay::{block_for, Delay};
pub use duration::Duration;
pub use embassy_time_driver::TICK_HZ;
pub use instant::Instant;
pub use timer::{timeout_at, with_timeout, Ticker, TimeoutError, Timer};
pub use timer::{with_deadline, with_timeout, Ticker, TimeoutError, Timer};
const fn gcd(a: u64, b: u64) -> u64 {
if b == 0 {

View file

@ -30,7 +30,7 @@ pub async fn with_timeout<F: Future>(timeout: Duration, fut: F) -> Result<F::Out
///
/// If the future completes before the deadline, its output is returned. Otherwise, on timeout,
/// work on the future is stopped (`poll` is no longer called), the future is dropped and `Err(TimeoutError)` is returned.
pub async fn timeout_at<F: Future>(at: Instant, fut: F) -> Result<F::Output, TimeoutError> {
pub async fn with_deadline<F: Future>(at: Instant, fut: F) -> Result<F::Output, TimeoutError> {
let timeout_fut = Timer::at(at);
pin_mut!(fut);
match select(fut, timeout_fut).await {

View file

@ -7,7 +7,7 @@
use defmt::info;
use embassy_executor::Spawner;
use embassy_rp::gpio::{Input, Level, Pull};
use embassy_time::{timeout_at, Duration, Instant, Timer};
use embassy_time::{with_deadline, Duration, Instant, Timer};
use {defmt_rtt as _, panic_probe as _};
pub struct Debouncer<'a> {
@ -49,7 +49,7 @@ async fn main(_spawner: Spawner) {
let start = Instant::now();
info!("Button Press");
match timeout_at(start + Duration::from_secs(1), btn.debounce()).await {
match with_deadline(start + Duration::from_secs(1), btn.debounce()).await {
// Button Released < 1s
Ok(_) => {
info!("Button pressed for: {}ms", start.elapsed().as_millis());
@ -61,7 +61,7 @@ async fn main(_spawner: Spawner) {
}
}
match timeout_at(start + Duration::from_secs(5), btn.debounce()).await {
match with_deadline(start + Duration::from_secs(5), btn.debounce()).await {
// Button released <5s
Ok(_) => {
info!("Button pressed for: {}ms", start.elapsed().as_millis());