| 1 | import x.executor |
| 2 | |
| 3 | fn main() { |
| 4 | mut ex := executor.new(queue_size: 4)! |
| 5 | updates := chan string{cap: 1} |
| 6 | |
| 7 | ex.try_post(fn [updates] () ! { |
| 8 | updates <- 'owner state updated' |
| 9 | })! |
| 10 | |
| 11 | ran := ex.run_one()! |
| 12 | if !ran { |
| 13 | eprintln('executor did not run the queued job') |
| 14 | exit(1) |
| 15 | } |
| 16 | |
| 17 | println(<-updates) |
| 18 | ex.stop() |
| 19 | if ex.run_one()! { |
| 20 | eprintln('unexpected job after stop') |
| 21 | exit(1) |
| 22 | } |
| 23 | ex.wait()! |
| 24 | } |
| 25 |