Initial commit
This commit is contained in:
commit
e729cd4268
9
config.ml
Normal file
9
config.ml
Normal 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
23
unikernel.ml
Normal 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
|
Loading…
Reference in a new issue