Skip to content

Commit

Permalink
Remove preset queue sizes from embassy-time
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Nov 30, 2024
1 parent a400af8 commit 9c8b89e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
17 changes: 0 additions & 17 deletions embassy-time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,6 @@ mock-driver = ["tick-hz-1_000_000"]
## To use this you must have a time driver provided.
generic-queue = []

#! The following features set how many timers are used for the generic queue. At most one
#! `generic-queue-*` feature can be enabled. If none is enabled, a default of 64 timers is used.
#!
#! When using embassy-time from libraries, you should *not* enable any `generic-queue-*` feature, to allow the
#! end user to pick.

## Generic Queue with 8 timers
generic-queue-8 = ["generic-queue"]
## Generic Queue with 16 timers
generic-queue-16 = ["generic-queue"]
## Generic Queue with 32 timers
generic-queue-32 = ["generic-queue"]
## Generic Queue with 64 timers
generic-queue-64 = ["generic-queue"]
## Generic Queue with 128 timers
generic-queue-128 = ["generic-queue"]

#! ### Tick Rate
#!
#! At most 1 `tick-*` feature can be enabled. If none is enabled, a default of 1MHz is used.
Expand Down
23 changes: 2 additions & 21 deletions embassy-time/src/queue_generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,6 @@ use heapless::Vec;

use crate::Instant;

#[cfg(feature = "generic-queue-8")]
const QUEUE_SIZE: usize = 8;
#[cfg(feature = "generic-queue-16")]
const QUEUE_SIZE: usize = 16;
#[cfg(feature = "generic-queue-32")]
const QUEUE_SIZE: usize = 32;
#[cfg(feature = "generic-queue-64")]
const QUEUE_SIZE: usize = 64;
#[cfg(feature = "generic-queue-128")]
const QUEUE_SIZE: usize = 128;
#[cfg(not(any(
feature = "generic-queue-8",
feature = "generic-queue-16",
feature = "generic-queue-32",
feature = "generic-queue-64",
feature = "generic-queue-128"
)))]
const QUEUE_SIZE: usize = 64;

#[derive(Debug)]
struct Timer {
at: Instant,
Expand Down Expand Up @@ -53,11 +34,11 @@ impl Ord for Timer {
}

/// A timer queue with a pre-determined capacity.
pub struct Queue {
pub struct Queue<const QUEUE_SIZE: usize> {
queue: Vec<Timer, QUEUE_SIZE>,
}

impl Queue {
impl<const QUEUE_SIZE: usize> Queue<QUEUE_SIZE> {
/// Creates a new timer queue.
pub const fn new() -> Self {
Self { queue: Vec::new() }
Expand Down

0 comments on commit 9c8b89e

Please sign in to comment.