23 lines
1.1 KiB
C
23 lines
1.1 KiB
C
// calogTimer.h -- calog timer library.
|
|
//
|
|
// One background thread drives every timer and invokes each script callback on its OWN
|
|
// owning context (marshalled like any calog function value, so the callback runs on the
|
|
// thread that created the timer). Three natives:
|
|
// timerAfter(ms, function) -> id fire the callback once, ms milliseconds from now
|
|
// timerEvery(ms, function) -> id fire the callback every ms milliseconds
|
|
// timerCancel(id) -> nil stop a pending or repeating timer (id from the above)
|
|
//
|
|
// If a timer's owning context is gone by the time it fires, the invoke fails cleanly and the
|
|
// timer auto-cancels itself. ms may be an integer or a real and must be non-negative. The
|
|
// registry (and its background thread) is process-wide and reference-counted across runtimes.
|
|
|
|
#ifndef CALOG_TIMER_H
|
|
#define CALOG_TIMER_H
|
|
|
|
#include "calog.h"
|
|
|
|
// Register the timer natives (timerAfter, timerEvery, timerCancel) on a runtime. The shared
|
|
// registry is reference-counted, so this is safe to call on any number of runtimes.
|
|
int32_t calogTimerRegister(CalogT *calog);
|
|
|
|
#endif
|