Module oc_wasm_futures::sleep

source ·
Expand description

Allows the caller to wait for an amount of time, measured either in computer uptime or in-game real time.

Sleep functions can be distinguished based on which measurement of time they use. In this axis, two measurements are available: uptime and world time. Uptime measures the time the computer has been in a loaded chunk since it was last booted; it passes only while the game is running (i.e. not paused or shut down) and the computer is in a loaded chunk. World time, in contrast, still only passes while the game is running (i.e. not paused or shut down), but it still passes even if the chunk containing the computer is unloaded; world time is therefore synchronized to the world’s day/night cycle.

Sleep functions can also be distinguished based on whether they accept a duration (a time period relative to the moment when they are called) or a deadline (a point in time at which the sleep will end).

Sleeping based on uptime is more efficient than sleeping based on world time. Therefore, if either is acceptable for your application, prefer uptime.

Structs§

  • A future that completes on the next timeslice.
  • A future that completes when a signal is in the signal queue.
  • A future that completes at a particular computer uptime.

Functions§