rasa/monotonic
Monotonic time and unique integer generation backed by Erlang’s monotonic_time/1 and unique_integer/1.
Types
The time unit used to convert the current erlang monotonic time. Passed directly to erlang’s monotonic_time/1.
pub type TimeUnit {
Second
Millisecond
Microsecond
Nanosecond
Native
}
Constructors
-
SecondMonotonic time in seconds.
-
MillisecondMonotonic time in milliseconds.
-
MicrosecondMonotonic time in microseconds.
-
NanosecondMonotonic time in nanoseconds.
-
NativeNative time unit used by the erlang runtime system.
Values
pub fn time(unit: TimeUnit) -> Int
Returns the current monotonic time in the given TimeUnit. Note that
consecutive calls may return the same value, especially with coarser
time units like Second or Millisecond.
pub fn unique() -> Int
Returns a unique integer that is monotonically ordered. Consecutive calls
are guaranteed to produce strictly increasing values, unlike time which
may return the same value from consecutive calls. Backed by erlang’s
unique_integer/1. These are strictly monotonically increasing
integers which are expensive to generate.