Skip to content

Commit 6abda1a

Browse files
committed
samples: work-philosophers: hand_worker: Run cargo fmt
Apply cargo fmt to the hand-written (and non-working) sample. Signed-off-by: David Brown <[email protected]>
1 parent e34d39d commit 6abda1a

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

samples/work-philosophers/src/hand_worker.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,31 @@
66
//! sense, this is structured more like various workers that are coordinating with devices, except
77
//! that we will use timeouts for the pauses.
88
9-
use core::{future::Future, pin::Pin, task::{Context, Poll}};
9+
use core::{
10+
future::Future,
11+
pin::Pin,
12+
task::{Context, Poll},
13+
};
1014

1115
use alloc::vec;
1216
use alloc::vec::Vec;
13-
use zephyr::{kio::{spawn, ContextExt}, printkln, sync::{Arc, SpinMutex}, time::Forever, work::{futures::JoinHandle, Signal, WorkQueue}};
17+
use zephyr::{
18+
kio::{spawn, ContextExt},
19+
printkln,
20+
sync::{Arc, SpinMutex},
21+
time::Forever,
22+
work::{futures::JoinHandle, Signal, WorkQueue},
23+
};
1424

15-
use crate::{get_random_delay, NUM_PHIL};
1625
pub use crate::Stats;
26+
use crate::{get_random_delay, NUM_PHIL};
1727

1828
pub fn phil(workq: &WorkQueue) -> Manager {
1929
let wake_manager = Arc::new(Signal::new().unwrap());
2030

21-
let actions: Vec<_> = (0..NUM_PHIL).map(|_| Arc::new(Action::new(wake_manager.clone()))).collect();
31+
let actions: Vec<_> = (0..NUM_PHIL)
32+
.map(|_| Arc::new(Action::new(wake_manager.clone())))
33+
.collect();
2234

2335
let phils: Vec<_> = (0..NUM_PHIL)
2436
.map(|i| Phil::new(actions[i].clone(), i))
@@ -57,7 +69,10 @@ pub struct Manager {
5769
impl Future for Manager {
5870
type Output = Stats;
5971

60-
fn poll(mut self: core::pin::Pin<&mut Self>, cx: &mut core::task::Context<'_>) -> core::task::Poll<Self::Output> {
72+
fn poll(
73+
mut self: core::pin::Pin<&mut Self>,
74+
cx: &mut core::task::Context<'_>,
75+
) -> core::task::Poll<Self::Output> {
6176
// Run through the actions, and see what they have to do.
6277
printkln!("Manager running");
6378

@@ -66,7 +81,7 @@ impl Future for Manager {
6681

6782
// Loop through all of the actions.
6883
for i in 0..self.actions.len() {
69-
// for (i, act) in self.actions.iter().enumerate() {
84+
// for (i, act) in self.actions.iter().enumerate() {
7085
let act = &self.actions[i];
7186
let mut change = None;
7287
let mut lock = act.fork.lock().unwrap();

0 commit comments

Comments
 (0)