Util_lwt_seaboar
A serializable timer which resumes on deserialize.
This is an alternative to simple timeouts which keeps track of how many seconds have elapsed and how many are remaining. The advantage is that it can be serialized/deserialized and resumed when the message router is restarted, which is why it lives in the module util_lwt_seaboar.
We use integer granularity on the clock because a) that's how Lwt_timeout does it (even though we're not using it) and b) ttl is given in seconds and expiry in minutes and it's probably overkill to get too precise.
By making `clock` a ref we can use `Lwt.async`, which is necessary to keep exceptions from being swallowed up. The handler should be careful not to raise any though because they will crash the entire program.
By using refs for `elapsed` and `remaining` we can keep the `Alarm_clock` structure itself immutable and update the refs from inside the thread.
`elapsed` is probably not all that useful and might be removed.
The thread will launch immediately when called like this and will work as long as the main program is wrapped in Lwt_main.run.
module Timer : sig ... end