package affect

  1. Overview
  2. Docs
Streamlined and natural concurrency model for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

affect-0.0.0.tbz
sha512=b328f6696e60c489da8cc2e8fad0537ca6634a39fc0c5de5840d4f98561f110617ef79ba8285ee8427dd99908c6b3d39114973598cddc5ded91abcce3b91b9a6

doc/affect.unix/Affect_unix/Ptime/index.html

Module Affect_unix.PtimeSource

POSIX time.

This time is measured by sampling this clock.

Warning. POSIX time does not increase monotonically, it is subject to operating system calendar time adjustements and can even go back in time. Use Mtime if you want to wait for wall-clock time spans.

Note. This is a minimal version of the ptime library which has more tools to deal with POSIX timestamp (e.g. date-time values) with the same representation, head there for more.

Sourcetype t

The type for picosecond precision POSIX timestamps in the range [min_stamp;max_stamp]. Note that POSIX timestamps, and hence values of this type are by definition always on the UTC timeline.

Waiting

Warning. This relies on an Unix.unblocker being setup on the executing domain.

Sourceval wait_until : t -> unit

wait_until t waits until the POSIX clock can be caught being greater or equal to the timestamp t. The actual supported resolution is unspecified and may also depend on scheduling but POSIX millisecond precision should be supported. Use observe_wait_until to measure the overshoot.

Sourceval observe_wait_until : t -> t

observe_wait_until is like wait_until but returns the value of the POSIX clock when the function returns.

Actions

Sourceval wait_until' : t -> 'tag -> 'tag Affect.Action.t

wait_until' t tag is the action for wait_until. The action invocation enables and synchronizes with tag when the POSIX clock can be caught to be greater or equal to the timestamp t.

POSIX spans

Sourcemodule Span : sig ... end

POSIX time spans.

Timestamps

Sourceval now : unit -> t

now () is the current value of the POSIX clock.

Sourceval epoch : t

epoch is 1970-01-01 00:00:00 UTC.

Sourceval min_stamp : t

min_stamp is 0000-01-01 00:00:00 UTC, the earliest timestamp representable.

Sourceval max_stamp : t

max_stamp is 9999-12-31 23:59:59.999999999999 UTC, the latest timestamp representable.

Predicates

Sourceval equal : t -> t -> bool

equal t0 t1 is true if and only if t0 and t1 are the same timestamps.

Sourceval compare : t -> t -> int

compare t0 t1 is a total order on timestamps that is compatible with timeline order.

Sourceval is_earlier : t -> than:t -> bool

is_earlier t ~than is true if and only if compare t than = -1.

Sourceval is_later : t -> than:t -> bool

is_later t ~than is true if and only if compare t than = 1.

Arithmetic

WARNING. A POSIX time span is not equal to an SI second based time span. Do not use these functions to perform calendar arithmetic or measure wall-clock durations, you will fail.

Sourceval diff : t -> t -> Span.t

diff t t' is the signed POSIX span t - t' that happens between the timestamps t and t'.

Sourceval add_span : t -> Span.t -> t option

add_span t d is timestamp t + d, that is t with the signed POSIX span d added. None is returned if the result is not in the range [min_stamp;max_stamp].

Sourceval sub_span : t -> Span.t -> t option

sub_span t d is the timestamp t - d, that is t with the signed POSIX span d subtracted. None is returned if the result is not in the range [min_stamp;max_stamp].

Conversions

Sourceval of_span : Span.t -> t option

of_span d is the POSIX time stamp that:

  • Happens at the POSIX span d after epoch if d is positive.
  • Happens at the POSIX span d before epoch if d is negative.

None is returned if the timestamp is not in the range [min_stamp;max_stamp].

Sourceval to_span : t -> Span.t

to_span t is the signed POSIX span that happen between t and epoch:

  • If the number is positive t happens after epoch.
  • If the number is negative t happens before epoch.
Sourceval of_float_s : float -> t option

of_float_s d is like of_span but with d as a floating point second POSIX span d. This function is compatible with the result of Unix.gettimeofday. Decimal fractional seconds beyond 1e-12 are truncated.

Sourceval to_float_s : t -> float

to_float_s t is like to_span but returns a floating point second POSIX span.

Warning. Due to floating point inaccuracies do not expect the function to round trip with of_float_s; especially near Ptime.min_stamp and Ptime.max_stamp.

Sourceval pp : Format.formatter -> t -> unit

pp formats an unspecified, approximative, representation of timestamp, it looks like RFC 3339 but it's not do not use for serializing.

The POSIX clock