Created
June 9, 2015 21:09
-
-
Save kayceesrk/51360c92cf2f99cd975c to your computer and use it in GitHub Desktop.
spawn continue
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
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