package mirage-mtime

  1. Overview
  2. Docs
Libraries and module types for a monotonic clock

Install

Dune Dependency

Authors

Maintainers

Sources

mirage-mtime-5.0.0.tbz
sha256=23075a0326728fc81f44fc503fd48ec1bdbc01bb55cbd3d8eea72bd0f9ecf465
sha512=3a4fa1dd7affffbe77df6e90bb40d229eb36d259ad463a602385331fb6d9f099d6cc1536545b4288b4b6933765da1ffc8b67d5b2cccaaa3af639c960ef993616

doc/mirage-mtime.unix/Mirage_mtime/index.html

Module Mirage_mtimeSource

include module type of struct include Mtime_clock end

Monotonic clock

Sourceval elapsed : unit -> Mtime.span

elapsed () is the monotonic time span elapsed since the beginning of the program.

Raises Sys_error, see error handling

Sourceval now : unit -> Mtime.t

now () is the current system-relative monotonic timestamp. Its absolute value is meaningless.

Raises Sys_error, see error handling

Sourceval period : unit -> Mtime.span option

period () is the clock's period as a monotonic time span (if available).

Time counters

The type for monotonic wall-clock time counters.

Sourceval counter : unit -> counter

counter () is a counter counting from now on.

Raises Sys_error, see error handling

Sourceval count : counter -> Mtime.span

count c is the monotonic time span elapsed since c was created.

Monotonic clock raw interface

val elapsed_ns : unit -> int64

elapsed_ns () is the unsigned 64-bit integer nanosecond monotonic time span elapsed since the beginning of the program.

Raises Sys_error, see error handling

Sourceval now_ns : unit -> int64

now_ns () is an unsigned 64-bit integer nanosecond system-relative monotonic timestamp. The absolute value is meaningless.

Raises Sys_error, see error handling

val period_ns : unit -> int64 option

period_ns () is the clock's period as an unsigned 64-bit integer nanosecond monotonic time span (if available).

Error handling

The functions elapsed, now, counter, elapsed_ns and now_ns raise Sys_error whenever they can't determine the current time or that it doesn't fit in Mtime's range. Usually this exception should only be catched at the toplevel of your program to log it and abort the program. It indicates a serious error condition in the system.

All the other functions, whose functionality is less essential, simply silently return None if they can't determine the information either because it is unavailable or because an error occured.

Platform support

OCaml

Innovation. Community. Security.