lona.time¶
Time intrinsics.
Monotonic Time¶
monotonic-time¶
Get monotonic timestamp.
Monotonically increasing:
Monotonically increasing, unaffected by clock adjustments. Use for measuring elapsed time and timeouts.
Sleep¶
sleep¶
Pause current process.
Sleep error cases:
Sleep takes non-zero time:
Yields CPU for at least ms milliseconds. Other processes continue running.
System Time¶
system-time¶
Get wall clock time.
;; @todo
(integer? (system-time)) ; => true
(> (system-time) 0) ; => true
;; System time should be positive and reasonable
(> (system-time) 1000000000000000000) ; => true ; After year 2001 in nanoseconds
May jump due to clock adjustments. Use monotonic-time for durations.
;; @todo
;; NOTE: Unlike monotonic-time, system-time can go backwards
;; due to NTP adjustments or manual clock changes.
;; For measuring durations, always use monotonic-time.
(def t1 (system-time))
(def t2 (system-time))
;; t2 >= t1 is NOT guaranteed for system-time
(integer? t1) ; => true
(integer? t2) ; => true
Appendix: Expected Derived Functions¶
The following are not intrinsics and should be implemented in Lonala:
timeout— create timeout referencewith-timeout— execute with deadlineafter— schedule delayed message to self