EMILUA(3em)
EMILUA(3em) π
okay bestie, welcome to the Emilua reference manual β this is the EMILUA(3em) page, and it's giving steady_timer main character energy. iykyk β¨
πΈ NAME πΈ
Emilua β Lua execution engine. periodt.
β¨ DESCRIPTION β¨
local timer = require('time').steady_timer
local t = timer.new()
spawn(function() print('Hello') end)
t:expires_after(2) --< 2 seconds
t:wait()
print('World')
It's a monotonic timer (i.e. the time points of the underlying clock cannot decrease as physical time moves forward). As in Boost.Asio (https://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/reference/steady_timer.html):
A waitable timer is always in one of two states: "expired" or "not expired". If thewait()orasync_wait()function is called on an expired timer, the wait operation will complete immediately. Changing an active waitable timerβs expiry time Changing the expiry time of a timer while there are pending asynchronous waits causes those wait operations to be cancelled.
π FUNCTIONS π
new() β steady_timer
local t = steady_timer.new()
Constructor. Returns a new steady_timer object. slay π
expires_at(self, tp: time.steady_clock.time_point) β integer
Forward the call to the Boost.Asio function with the same name (https://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/reference/basic_waitable_timer/expires_at.html):
Set the timerβs expiry time as an absolute time. Any pending asynchronous wait operations will be cancelled. The handler for each cancelled operation will be invoked with the boost::asio::error::operation_aborted error code. Return Value The number of asynchronous operations that were cancelled.
expires_after(self, secs: number) β integer
Forward the call to the Boost.Asio function with the same name (https://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/reference/basic_waitable_timer/expires_after.html):
Set the timerβs expiry time relative to now. Any pending asynchronous wait operations will be cancelled. The handler for each cancelled operation will be invoked with the boost::asio::error::operation_aborted error code. Return Value The number of asynchronous operations that were cancelled.
Expiry time is given in seconds. π
wait(self)
Initiate a wait operation on the timer and block the current fiber until one of these events occurs:
- The timer has expired.
- The timer was cancelled, in which case it raises
boost::asio::error::operation_aborted.
cancel(self) β integer
Cancel any operations that are waiting on the timer. Returns the number of asynchronous operations that were cancelled.
π PROPERTIES π
expiry: time.steady_clock.time_point
The timerβs expiry time as an absolute time.
Whether the timer has expired or not does not affect this value.
mwah π β source/version: Emilua 0.12.1-nixpkgs1; date: 1980-01-01; page: EMILUA(3em). xoxo, your Unix bestie π«Ά
π¦ where this page comes from
- nixos 26.05: emilua 0.12.1
- nixpkgs unstable: emilua 0.12.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms