Std. System
(Cure Standard Library v0.37.2)
View Source
System operations: time, process identity, node info, exit.
Light wrappers around :erlang and :os BIFs. exit/1 halts
the whole BEAM node -- use with care.
Examples
use Std.System
cpu_count() # e.g. 8
timestamp_ms() > 0 # => true
node() == :nonode@nohost # true without -sname
Summary
Types
Group tag consumed by Cure.Stdlib.Preload.
Units accepted by BEAM wall-clock time operations. Constructors are
translated at the private foreign boundary; callers cannot pass an
arbitrary atom that :os.system_time/1 does not understand.
Functions
Number of logical processors available to the VM.
Halt never reports a meaningful atom to its caller. The raw declaration records BEAM's boundary shape; this safe surface communicates that there is no result to inspect if a host substitutes or intercepts the call.
Native monotonic-time reading in implementation-defined units.
Use for measuring durations (a - b is meaningful); not
wall-clock.
Atom name of the local node.
Running OTP release version, e.g. "27".
Halt the whole BEAM node with the given exit status.
:erlang.system_info/1 answers a different shape for every key, so it gets
one private extern per key rather than a single polymorphic declaration: an
@extern is a direct remote call with no marshalling, so an unconstrained
-> t would let any caller claim any type for the BIF's result.
OS wall-clock time in unit (typically :second, :millisecond,
:microsecond, or :nanosecond).
OS wall-clock time in unit, typed.
Current millisecond timestamp since the Unix epoch.
Current microsecond timestamp since the Unix epoch.
Types
enum TimeUnit
Second
Millisecond
Microsecond
Nanosecond
Group tag consumed by Cure.Stdlib.Preload.
Units accepted by BEAM wall-clock time operations. Constructors are
translated at the private foreign boundary; callers cannot pass an
arbitrary atom that :os.system_time/1 does not understand.
Functions
fn cpu_count() -> Int
Number of logical processors available to the VM.
fn exit(code: Int) -> Unit
Halt never reports a meaningful atom to its caller. The raw declaration records BEAM's boundary shape; this safe surface communicates that there is no result to inspect if a host substitutes or intercepts the call.
fn monotonic_time() -> Int
Native monotonic-time reading in implementation-defined units.
Use for measuring durations (a - b is meaningful); not
wall-clock.
fn node() -> Atom
Atom name of the local node.
fn otp_version() -> String
Running OTP release version, e.g. "27".
fn raw_exit(code: Int) -> Atom
Halt the whole BEAM node with the given exit status.
fn raw_logical_processors(key: Atom) -> Int
fn raw_otp_release(key: Atom) -> List(Char)
:erlang.system_info/1 answers a different shape for every key, so it gets
one private extern per key rather than a single polymorphic declaration: an
@extern is a direct remote call with no marshalling, so an unconstrained
-> t would let any caller claim any type for the BIF's result.
:otp_release answers a code-point list. List(Char) erases to a bare
charlist, which is exactly that; nominal String erases to the tagged pair
{String, chars}, which the BIF does not build -- so the extern is declared
at List(Char) and otp_version wraps.
fn raw_system_time(unit: Atom) -> Int
OS wall-clock time in unit (typically :second, :millisecond,
:microsecond, or :nanosecond).
fn system_time(unit: TimeUnit) -> Int
OS wall-clock time in unit, typed.
The typed counterpart of raw_system_time/1: converts the TimeUnit
constructor to its BEAM atom and delegates. Prefer this over the raw
extern at call sites.
fn time_unit_atom(unit: TimeUnit) -> Atom
fn timestamp_ms() -> Int
Current millisecond timestamp since the Unix epoch.
fn timestamp_us() -> Int
Current microsecond timestamp since the Unix epoch.