ELScheduler

ELScheduler
Login

Embeddable Lua Scheduler is a Lua module to manage timers.

Timers are bound to a point in time and are triggered when current_time >= timer_time.

Warning: Repeated timers are implemented as regular timers re-added if needed before being triggered. Thus, a timer can only be triggered once per tick; triggers may be shifted or discarded based on the tick period.

Performance note: A binary heap is used to manage timer priorities.

Install

See src/, rockspecs/ or luarocks.

API

Module

Scheduler ([time]) -> scheduler

Create a new scheduler. This function is returned when loading the module.

Scheduler

scheduler:timer (delay, [count, ] callback) -> timer

Create a timer.

scheduler:tick (time)

Do a scheduler tick. Time going backwards will not change/advance the scheduler's time.

Fields

The expression #self.timers gives the number of pending timers.

Timer

timer:remove ()

Remove the timer. Idempotent.

Once a timer is removed, it will never trigger again.

Fields