Initial commit

master
Reynir Björnsson 5 years ago
commit e729cd4268

@ -0,0 +1,9 @@
open Mirage
let main =
foreign
~packages:[package "duration"; package "lwt_react"]
"Unikernel.Hello" (time @-> job)
let () =
register "hello" [main $ default_time]

@ -0,0 +1,23 @@
open Lwt.Infix
module Hello (Time : Mirage_time_lwt.S) = struct
let start _time =
let hello, run =
let open Lwt_react in
let e, send = E.create () in
let run () =
let rec loop n =
if n > 0
then begin
send "hello";
Time.sleep_ns (Duration.of_sec 1) >>= fun () ->
loop (n-1)
end else Lwt.return_unit in
loop 4 in
e, run in
let printer = Lwt_react.E.map (fun s -> Logs.info (fun f -> f "%s" s)) hello in
run ()
end
Loading…
Cancel
Save