-
-
Save seliopou/67ca2a75a12e78962fb6f30a9dcc4c24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(executable (name test_rng) (libraries async mirage-crypto-rng-async) (preprocess (pps ppx_jane))) |
This file contains hidden or 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
open Core | |
open Async | |
let main () = | |
let time_source = Synchronous_time_source.wall_clock () in | |
let print_next_alarm_time () = | |
let next_alarm_fires_in = | |
Option.map | |
(Synchronous_time_source.next_alarm_fires_at time_source) | |
~f:(fun next -> Time_ns.diff next (Synchronous_time_source.now time_source)) | |
in | |
print_s [%message "" (next_alarm_fires_in : Time_ns.Span.t Option.t)]; | |
in | |
print_next_alarm_time (); | |
Mirage_crypto_rng_async.initialize (); | |
print_next_alarm_time (); | |
let rand = Mirage_crypto_rng.generate 8 in | |
let bs = Bigstring.sub ~pos:rand.off ~len:rand.len rand.buffer in | |
print_endline (Bigstring.Hexdump.to_string_hum bs); | |
Synchronous_time_source.run_after | |
time_source | |
(Time_ns.Span.of_int_sec 1) | |
(fun () -> | |
print_next_alarm_time (); | |
Shutdown.shutdown 0) | |
;; | |
let () = ignore (Scheduler.go_main ~main () : never_returns) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment