Processes can also be suspended and resumed using events via the
control/with
construct.
signal ctrl;;
let process p = control for i = 1 to max_int do print_int i; print_newline (); pause done with ctrl done ;;
#run p;;The first emission of the
ctrl
event suspends the execution.
emit ctrl;;The second emission of
ctrl
resumes the execution at the
point where it was suspended.
emit ctrl;;The next emission suspends the execution again.
emit ctrl;;