Skip to content

Commit c8822b4

Browse files
authored
Restore multiple-integrated timer queues (#3166)
1 parent fc2a656 commit c8822b4

File tree

8 files changed

+27
-34
lines changed

8 files changed

+27
-34
lines changed

esp-hal-embassy/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Re-added the `multiple-integrated` timer queue flavour (#3166)
13+
1214
### Changed
1315

1416
### Fixed

esp-hal-embassy/build.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ fn main() -> Result<(), Box<dyn StdError>> {
4949
),
5050
(
5151
"timer-queue",
52-
//"<p>The flavour of the timer queue provided by this crate. Accepts one of `single-integrated`, `multiple-integrated` or `generic`. Integrated queues require the `executors` feature to be enabled.</p><p>If you use embassy-executor, the `single-integrated` queue is recommended for ease of use, while the `multiple-integrated` queue is recommended for performance. The `multiple-integrated` option needs one timer per executor.</p><p>The `generic` queue allows using embassy-time without the embassy executors.</p>",
53-
"<p>The flavour of the timer queue provided by this crate. Accepts either `single-integrated` or `generic`. Integrated queues require the `executors` feature to be enabled.</p><p>If you use embassy-executor, the `single-integrated` queue is recommended.</p><p>The `generic` queue allows using embassy-time without the embassy executors.</p>",
52+
"<p>The flavour of the timer queue provided by this crate. Accepts one of `single-integrated`, `multiple-integrated` or `generic`. Integrated queues require the `executors` feature to be enabled.</p><p>If you use embassy-executor, the `single-integrated` queue is recommended for ease of use, while the `multiple-integrated` queue is recommended for performance. The `multiple-integrated` option needs one timer per executor.</p><p>The `generic` queue allows using embassy-time without the embassy executors.</p>",
5453
Value::String(if cfg!(feature = "executors") {
5554
String::from("single-integrated")
5655
} else {
@@ -70,10 +69,9 @@ fn main() -> Result<(), Box<dyn StdError>> {
7069

7170
match string.as_str() {
7271
"single-integrated" => Ok(()), // preferred for ease of use
73-
//"multiple-integrated" => Ok(()), // preferred for performance
72+
"multiple-integrated" => Ok(()), // preferred for performance
7473
"generic" => Ok(()), // allows using embassy-time without the embassy executors
75-
//_ => Err(Error::Validation(format!("Expected 'single-integrated', 'multiple-integrated' or 'generic', found {string}")))
76-
_ => Err(Error::Validation(format!("Expected 'single-integrated' or 'generic', found {string}")))
74+
_ => Err(Error::Validation(format!("Expected 'single-integrated', 'multiple-integrated' or 'generic', found {string}")))
7775
}
7876
})))
7977
),
@@ -96,9 +94,9 @@ fn main() -> Result<(), Box<dyn StdError>> {
9694
println!("cargo:rustc-cfg=integrated_timers");
9795
println!("cargo:rustc-cfg=single_queue");
9896
}
99-
// Value::String(s) if s.as_str() == "multiple-integrated" => {
100-
// println!("cargo:rustc-cfg=integrated_timers");
101-
//}
97+
Value::String(s) if s.as_str() == "multiple-integrated" => {
98+
println!("cargo:rustc-cfg=integrated_timers");
99+
}
102100
Value::String(s) if s.as_str() == "generic" => {
103101
println!("cargo:rustc-cfg=generic_timers");
104102
println!("cargo:rustc-cfg=single_queue");

esp-hal-embassy/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
//!
3232
//! Initialization requires a number of timers to be passed in. The number of
3333
//! timers required depends on the timer queue flavour used, as well as the
34-
//! number of executors started.
35-
// TODO restore this:
36-
// If you use the `multiple-integrated` timer
37-
// queue flavour, then you need to pass as many timers as you start executors.
38-
// In other cases, you can pass a single timer.
34+
//! number of executors started. If you use the `multiple-integrated` timer
35+
//! queue flavour, then you need to pass as many timers as you start executors.
36+
//! In other cases, you can pass a single timer.
37+
//!
3938
//! ## Configuration
4039
//!
4140
//! You can configure the behaviour of the embassy runtime by using the
@@ -156,10 +155,11 @@ impl_array!(4);
156155
/// - A mutable static slice of `OneShotTimer` instances
157156
/// - A mutable static array of `OneShotTimer` instances
158157
/// - A 2, 3, 4 element array of `AnyTimer` instances
159-
// TODO: restore this:
160-
// /// Note that if you use the `multiple-integrated` timer-queue flavour, then
161-
// /// you need to pass as many timers as you start executors. In other cases,
162-
// /// you can pass a single timer.
158+
///
159+
/// Note that if you use the `multiple-integrated` timer-queue flavour, then
160+
/// you need to pass as many timers as you start executors. In other cases,
161+
/// you can pass a single timer.
162+
///
163163
/// # Examples
164164
///
165165
/// ```rust, no_run

esp-hal-embassy/src/time_driver.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,19 @@ impl Alarm {
9393
/// as well as to schedule a wake-up at a certain time.
9494
///
9595
/// We are free to choose how we implement these features, and we provide
96-
/// two options:
96+
/// three options:
9797
///
9898
/// - If the `generic` feature is enabled, we implement a single timer queue,
9999
/// using the implementation provided by embassy-time-queue-driver.
100100
/// - If the `single-integrated` feature is enabled, we implement a single timer
101101
/// queue, using our own integrated timer implementation. Our implementation
102102
/// is a copy of the embassy integrated timer queue, with the addition of
103103
/// clearing the "owner" information upon dequeueing.
104-
// TODO: restore this and update the "two options" above:
105-
// - If the `multiple-integrated` feature is enabled, we provide a separate
106-
// timer queue for each executor. We store a separate timer queue for each
107-
// executor, and we use the scheduled task's owner to determine which queue to
108-
// use. This mode allows us to use less disruptive locks around the timer
109-
// queue, but requires more timers - one per timer queue.
104+
/// - If the `multiple-integrated` feature is enabled, we provide a separate
105+
/// timer queue for each executor. We store a separate timer queue for each
106+
/// executor, and we use the scheduled task's owner to determine which queue
107+
/// to use. This mode allows us to use less disruptive locks around the timer
108+
/// queue, but requires more timers - one per timer queue.
110109
pub(super) struct EmbassyTimer {
111110
/// The timer queue, if we use a single one (single-integrated, or generic).
112111
#[cfg(single_queue)]

hil-test/.cargo/config.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ rustflags = [
1818

1919
[env]
2020
DEFMT_LOG = "info"
21-
# TODO restore multiple-integrated
22-
#ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE="multiple-integrated"
23-
ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE="single-integrated"
21+
ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE="multiple-integrated"
2422

2523
[unstable]
2624
build-std = ["core", "alloc"]

hil-test/tests/embassy_interrupt_executor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
55
//% FEATURES: unstable embassy
66
//% ENV(single_integrated): ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE = single-integrated
7-
// TODO restore multiple-integrated
8-
// ENV(multiple_integrated): ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE = multiple-integrated
7+
//% ENV(multiple_integrated): ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE = multiple-integrated
98
//% ENV(generic_queue): ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE = generic
109
//% ENV(generic_queue): ESP_HAL_EMBASSY_CONFIG_GENERIC_QUEUE_SIZE = 16
1110
//% ENV(default_with_waiti): ESP_HAL_EMBASSY_CONFIG_LOW_POWER_WAIT = true

hil-test/tests/embassy_interrupt_spi_dma.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
//% CHIPS: esp32 esp32s2 esp32s3 esp32c3 esp32c6 esp32h2
44
//% FEATURES: unstable embassy
55
//% ENV(single_integrated): ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE = single-integrated
6-
// TODO restore multiple-integrated
7-
// ENV(multiple_integrated): ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE = multiple-integrated
6+
//% ENV(multiple_integrated): ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE = multiple-integrated
87
//% ENV(generic_queue): ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE = generic
98
//% ENV(generic_queue): ESP_HAL_EMBASSY_CONFIG_GENERIC_QUEUE_SIZE = 16
109

qa-test/.cargo/config.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ rustflags = [
2828

2929
[env]
3030
ESP_LOG = "info"
31-
# TODO restore multiple-integrated
32-
#ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE="multiple-integrated"
33-
ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE="single-integrated"
31+
ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE="multiple-integrated"
3432

3533
[unstable]
3634
build-std = ["alloc", "core"]

0 commit comments

Comments
 (0)