Initial commit

This commit is contained in:
Reynir Björnsson 2018-08-29 17:17:49 +02:00
commit e729cd4268
2 changed files with 32 additions and 0 deletions

9
config.ml Normal file
View file

@ -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]

23
unikernel.ml Normal file
View file

@ -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