| 1 | import x.executor |
| 2 | |
| 3 | struct FakeHandle { |
| 4 | mut: |
| 5 | calls int |
| 6 | } |
| 7 | |
| 8 | fn main() { |
| 9 | mut owner := executor.new(queue_size: 4)! |
| 10 | result := chan int{cap: 1} |
| 11 | mut handle := FakeHandle{} |
| 12 | |
| 13 | owner.try_post(fn [mut handle, result] () ! { |
| 14 | handle.calls++ |
| 15 | handle.calls++ |
| 16 | result <- handle.calls |
| 17 | })! |
| 18 | |
| 19 | if !owner.run_one()! { |
| 20 | eprintln('owner job did not run') |
| 21 | exit(1) |
| 22 | } |
| 23 | calls := <-result |
| 24 | if calls != 2 { |
| 25 | eprintln('unexpected handle call count: ${calls}') |
| 26 | exit(1) |
| 27 | } |
| 28 | |
| 29 | println('synthetic FFI handle calls=${calls}') |
| 30 | owner.stop() |
| 31 | if owner.run_one()! { |
| 32 | eprintln('unexpected owner job after stop') |
| 33 | exit(1) |
| 34 | } |
| 35 | owner.wait()! |
| 36 | } |
| 37 | |