Created
October 26, 2018 11:43
-
-
Save rand00/16e6e09fb8f779b4c35d4b6f8acb36cd to your computer and use it in GitHub Desktop.
Structured concurrency semantics?
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
(*Example from http://libdill.org/ rewritten in Lwt*) | |
open Lwt | |
let rec worker s = | |
Lwt_io.printl s >>= fun () -> | |
Lwt_unix.sleep @@ Random.float 0.5 >>= fun () -> | |
worker s | |
let main = | |
let _ = worker "Hello!" in | |
let _ = worker "World!" in | |
Lwt_unix.sleep 5. | |
let _ = | |
Random.self_init (); | |
Lwt_main.run main | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment