Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: fix notices for pendulum-simulation, simplify --workers opt…
…ion handling, fix assertions for `v test examples/pendulum-simulation`
- Loading branch information
Showing
6 changed files
with
31 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,32 @@ | ||
module main | ||
|
||
import log | ||
import benchmark | ||
import sim | ||
import sim.anim | ||
import sim.args as simargs | ||
|
||
fn main() { | ||
unbuffer_stdout() | ||
args := simargs.parse_args(extra_workers: 1)! as simargs.ParallelArgs | ||
|
||
mut app := anim.new_app(args) | ||
mut workers := []thread{cap: args.workers} | ||
|
||
mut bmark := benchmark.start() | ||
|
||
defer { | ||
app.request_chan.close() | ||
sim.log('Waiting for workers to finish') | ||
log.info('Waiting for workers to finish') | ||
workers.wait() | ||
app.result_chan.close() | ||
sim.log('Workers finished!') | ||
log.info('Workers finished!') | ||
bmark.measure(@FN) | ||
sim.log('Done!') | ||
log.info('Done!') | ||
} | ||
|
||
for id in 0 .. args.workers { | ||
workers << spawn sim.sim_worker(id, app.request_chan, [app.result_chan]) | ||
} | ||
|
||
handle_request := fn [app] (request &sim.SimRequest) ! { | ||
app.request_chan <- request | ||
} | ||
|
||
spawn app.gg.run() | ||
|
||
sim.run(args.params, grid: args.grid, on_request: sim.SimRequestHandler(handle_request)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters