Skip to content

Commit 33cf3f7

Browse files
committed
samples: bench: cargo fmt
Update formatting from `cargo fmt`. Signed-off-by: David Brown <[email protected]>
1 parent 07728ff commit 33cf3f7

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

samples/bench/src/executor.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ use core::{ffi::c_int, sync::atomic::Ordering};
88
use alloc::format;
99
use embassy_executor::SendSpawner;
1010
use embassy_futures::yield_now;
11+
#[allow(unused_imports)]
12+
use embassy_sync::semaphore::{FairSemaphore, GreedySemaphore};
1113
use embassy_sync::{
12-
blocking_mutex::raw::CriticalSectionRawMutex,
13-
channel::Channel,
14-
semaphore::Semaphore,
14+
blocking_mutex::raw::CriticalSectionRawMutex, channel::Channel, semaphore::Semaphore,
1515
signal::Signal,
1616
};
17-
#[allow(unused_imports)]
18-
use embassy_sync::semaphore::{GreedySemaphore, FairSemaphore};
1917
use static_cell::StaticCell;
2018
use zephyr::{embassy::Executor, sync::atomic::AtomicBool};
2119

@@ -24,7 +22,7 @@ use crate::{BenchTimer, Command, TestResult, NUM_THREADS, THREAD_STACK_SIZE};
2422
/// As the tests do exercise different executors at different priorities, use the critical section
2523
/// variant.
2624
// type ASemaphore = GreedySemaphore<CriticalSectionRawMutex>;
27-
type ASemaphore = FairSemaphore<CriticalSectionRawMutex, {NUM_THREADS + 2}>;
25+
type ASemaphore = FairSemaphore<CriticalSectionRawMutex, { NUM_THREADS + 2 }>;
2826

2927
/// A Signal for reporting back spawners.
3028
type SpawnerSignal = Signal<CriticalSectionRawMutex, SendSpawner>;
@@ -281,7 +279,6 @@ async fn main_run(this: &'static AsyncTests) {
281279
} else {
282280
this.spawners[0].spawn(low_worker(this, command)).unwrap();
283281
}
284-
285282
} else {
286283
this.spawners[1].spawn(high_worker(this, command)).unwrap();
287284
this.spawners[1].spawn(low_worker(this, command)).unwrap();
@@ -349,5 +346,4 @@ fn executor_thread(exec: &'static StaticCell<Executor>, spawner_sig: &'static Sp
349346

350347
// For debugging
351348
#[unsafe(no_mangle)]
352-
extern "C" fn invalid_spinlock(_l: *mut zephyr::raw::k_spinlock, _thread: u32, _id: u32) {
353-
}
349+
extern "C" fn invalid_spinlock(_l: *mut zephyr::raw::k_spinlock, _thread: u32, _id: u32) {}

samples/bench/src/lib.rs

+4-17
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ use alloc::collections::vec_deque::VecDeque;
1616
use alloc::vec;
1717
use executor::AsyncTests;
1818
use static_cell::StaticCell;
19+
use zephyr::define_work_queue;
1920
use zephyr::raw::k_yield;
2021
use zephyr::sync::{PinWeak, SpinMutex};
2122
use zephyr::time::NoWait;
22-
use zephyr::work::{SimpleAction, Work, WorkQueueDecl};
23+
use zephyr::work::{SimpleAction, Work};
2324
use zephyr::{
2425
kconfig::CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC,
2526
printkln,
@@ -40,7 +41,7 @@ const NUM_THREADS: usize = 6;
4041

4142
/// Stack size to use for the threads.
4243
#[cfg(target_pointer_width = "32")]
43-
const THREAD_STACK_SIZE: usize = 4*1024;
44+
const THREAD_STACK_SIZE: usize = 4 * 1024;
4445

4546
/// Stack size to use for the threads.
4647
#[cfg(target_pointer_width = "64")]
@@ -803,21 +804,7 @@ impl<'a> BenchTimer<'a> {
803804
}
804805
}
805806

806-
/// Static declaration of work queue. This is a working template for how this will be generated
807-
/// through the macro.
808-
static WORKQ: WorkQueueDecl<WORK_STACK_SIZE> = WorkQueueDecl::new(
809-
&WORKQ_STACK,
810-
zephyr::raw::k_work_queue_config {
811-
name: c"WORKQ".as_ptr(),
812-
no_yield: true,
813-
essential: false,
814-
},
815-
5,
816-
);
817-
818-
#[unsafe(link_section = ".noinit.WORKQ_STACK")]
819-
static WORKQ_STACK: zephyr::thread::ThreadStack<WORK_STACK_SIZE> =
820-
zephyr::thread::ThreadStack::new();
807+
define_work_queue!(WORKQ, WORK_STACK_SIZE, priority = 5, no_yield = true);
821808

822809
static SEMS: [Semaphore; NUM_THREADS] = [const { Semaphore::new(0, u32::MAX) }; NUM_THREADS];
823810
static BACK_SEMS: [Semaphore; NUM_THREADS] = [const { Semaphore::new(0, u32::MAX) }; NUM_THREADS];

0 commit comments

Comments
 (0)