Skip to content

Commit 7758fe5

Browse files
committed
samples: philosophers: Switch condsync to dynamic
Use the simpler `new` methods instead of static allocaiton. Signed-off-by: David Brown <[email protected]>
1 parent 70e2710 commit 7758fe5

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

samples/philosophers/src/condsync.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::{
1010
ForkSync,
1111
NUM_PHIL,
1212
};
13-
use zephyr::kobj_define;
1413
use zephyr::sync::Mutex;
1514
use zephyr::sync::Condvar;
1615
// use zephyr::time::Forever;
@@ -26,12 +25,10 @@ pub struct CondSync {
2625
impl CondSync {
2726
#[allow(dead_code)]
2827
pub fn new() -> CondSync {
29-
let sys_mutex = MUTEX.init_once(()).unwrap();
30-
let sys_condvar = CONDVAR.init_once(()).unwrap();
31-
32-
let lock = Mutex::new_from([false; NUM_PHIL], sys_mutex);
33-
let cond = Condvar::new_from(sys_condvar);
34-
CondSync { lock, cond }
28+
CondSync {
29+
lock: Mutex::new([false; NUM_PHIL]),
30+
cond: Condvar::new(),
31+
}
3532
}
3633
}
3734

@@ -51,8 +48,3 @@ impl ForkSync for CondSync {
5148
self.cond.notify_all();
5249
}
5350
}
54-
55-
kobj_define! {
56-
static MUTEX: StaticMutex;
57-
static CONDVAR: StaticCondvar;
58-
}

0 commit comments

Comments
 (0)