module Sync:sig
..end
Synchronized execution queue.
Any action can be pushed to this FIFO queue, in order to be executed by Bogue's main loop at the start of the next graphical frame.
For any action that is not super urgent, it is a good idea to use this `Sync` module, instead of launching the action directly from a thread that may be difficult to control. In this way, we ensure that the action is not executed in the middle of rendering the graphics, or between various modifications of the board (events, keyboard focus, etc.).
val push : (unit -> unit) -> unit
push action
registers the action
to be executed by the mainloop at the
start of the next frame, or at a subsequent frame if the queue is already
large.
Warning: the action may also call push
itself, but since
there is only one execution queue, the second action will be executed only
after the first action terminates. For instance this program:
Sync.push (fun () ->
print_endline "push 1";
Sync.push (fun () ->
print_endline "push 2";
print_endline "end 2");
print_endline "end 1");
print_endline "Creating board";
W.label "Checking sync... see console"
|> L.resident
|> Main.of_layout
|> Main.run
will print:
Creating board push 1 end 1 push 2 end 2