|
10 | 10 |
|
11 | 11 | extern crate alloc;
|
12 | 12 |
|
13 |
| -use zephyr::{printkln, sync::Arc, task::Wake, time::{Duration, NoWait}, work::futures::FutureWorkPoll}; |
| 13 | +use zephyr::{printkln, time::Duration, work::futures::{sleep, WorkBuilder}}; |
14 | 14 |
|
15 | 15 | /// How many philosophers. There will be the same number of forks.
|
16 | 16 | const _NUM_PHIL: usize = 6;
|
@@ -47,11 +47,7 @@ extern "C" fn rust_main() {
|
47 | 47 | // TODO: How to do as much on the stack as we can, for now, don't worry too much.
|
48 | 48 | // let mut th = pin!(th);
|
49 | 49 |
|
50 |
| - let mut th = FutureWorkPoll::new(th); |
51 |
| - let result = th.as_mut().submit(NoWait).unwrap(); |
52 |
| - if !result.enqueued() { |
53 |
| - panic!("Problem submitting initial work: {:?}", result); |
54 |
| - } |
| 50 | + let th = WorkBuilder::new().start(th); |
55 | 51 |
|
56 | 52 | let result = th.sync_join();
|
57 | 53 | printkln!("th result: {:?}", result);
|
@@ -96,25 +92,21 @@ extern "C" fn rust_main() {
|
96 | 92 | */
|
97 | 93 | }
|
98 | 94 |
|
99 |
| -/// Our local workqueue worker. |
100 |
| -struct PWaker; |
101 |
| - |
102 |
| -impl Wake for PWaker { |
103 |
| - fn wake(this: Arc<Self>) { |
104 |
| - // Note that being able to call this 'self' would require the unstable |
105 |
| - // `abritrary_self_types` feature. |
106 |
| - let _ = this; |
107 |
| - todo!() |
108 |
| - } |
109 |
| -} |
110 |
| - |
111 | 95 | async fn phil_thread(n: usize) -> usize {
|
112 | 96 | printkln!("Child {} started", n);
|
113 |
| - zephyr::work::futures::sleep(Duration::millis_at_least(1000)).await; |
| 97 | + show_it().await; |
| 98 | + sleep(Duration::millis_at_least(1000)).await; |
114 | 99 | printkln!("Child {} done sleeping", n);
|
115 | 100 | 42
|
116 | 101 | }
|
117 | 102 |
|
| 103 | +async fn show_it() { |
| 104 | + for i in 0..10 { |
| 105 | + sleep(Duration::millis_at_least(1)).await; |
| 106 | + printkln!("Tick: {i}"); |
| 107 | + } |
| 108 | +} |
| 109 | + |
118 | 110 | /*
|
119 | 111 | fn phil_thread(n: usize, syncer: Arc<dyn ForkSync>, stats: Arc<Mutex<Stats>>) {
|
120 | 112 | printkln!("Child {} started: {:?}", n, syncer);
|
|
0 commit comments