Skip to content

monotonic time

Chris Vine edited this page Dec 4, 2019 · 1 revision

The (a-sync monotonic-time) module provides two procedures. It is loaded by the (a-sync event-loop) module.


(have-monotonic-time?)

This procedure indicates whether the get-time procedure (see below) provides a monotonic clock. Almost all modern linux/unix-like systems will do so. This procedure may return #f if windows is in use, or if the guile-a-sync library was cross-compiled on one architecture for a different one.


(get-time)

This returns the current time as a (secs . usecs) pair from some arbitrary epoch. If (have-monotonic-time) returns #t, then this will be derived from a monotonic clock obtained by calling the clock_gettime() POSIX function with a CLOCK_MONOTONIC argument. This procedure is used by the (a-sync event-loop) module timeout implementation. This procedure throws an 'a-sync-exception (which would propagate out of the event-loop-run! procedure if the event loop in the (a-sync event-loop) module is in use) if the library has been configured for monotonic time at configuration time but it is not in fact supported. However this is not worth catering for by user code as it should never happen - the library configuration macros should always give the correct answer.