Skip to content

Instantly share code, notes, and snippets.

@kayceesrk
Created June 9, 2015 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kayceesrk/51360c92cf2f99cd975c to your computer and use it in GitHub Desktop.
Save kayceesrk/51360c92cf2f99cd975c to your computer and use it in GitHub Desktop.
spawn continue
effect Wut : unit
effect Wat : unit
let rec foo n =
Printf.printf "[%d] foo\n%!" @@ Domain.self ();
Unix.sleep 1;
if n == 0 then
(perform Wat; foo 1)
else
(perform Wut; foo 1)
let rec bar () =
Printf.printf "[%d] bar\n%!" @@ Domain.self ();
Unix.sleep 1;
bar ()
let () =
match foo 0 with
| v -> v
| effect Wut k -> continue k ()
| effect Wat k ->
Domain.spawn (continue k);
bar ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment