Hi Denis,
TinyMUX has local.cpp (inspired by Penn's local.c), which gives you hooks for startup, shutdown, connect/disconnect, object creation/destruction, and database dump events. You can add hardcoded commands and functions there too.
For a repeating timer specifically, TinyMUX uses its internal task scheduler. In local_startup(), you'd register a recurring task like this:
static void my_local_timer(void *pUnused, int iUnused)
{
UNUSED_PARAMETER(pUnused);
UNUSED_PARAMETER(iUnused);
// Your periodic work here.
// Re-schedule ourselves.
CLinearTimeAbsolute ltaNow;
ltaNow.GetUTC();
CLinearTimeDelta ltd;
ltd.SetSeconds(1); // Run again in 1 second.
scheduler.DeferTask(ltaNow + ltd, PRIORITY_OBJECT,
my_local_timer, 0, 0);
}
void local_startup(void)
{
// ... existing function/command registration ...
// Start the timer.
CLinearTimeAbsolute ltaNow;
ltaNow.GetUTC();
CLinearTimeDelta ltd;
ltd.SetSeconds(1);
scheduler.DeferTask(ltaNow + ltd, PRIORITY_OBJECT,
my_local_timer, 0, 0);
}
This is the same pattern used internally for database checkpoints, idle checks, @daily, and keepalives — see timer.cpp for examples. The task re-schedules itself at the end of each invocation.
The scheduler works with CLinearTimeAbsolute/CLinearTimeDelta which support sub-second precision. There's no fixed tick rate — GANL blocks until either network I/O arrives or the next scheduled task is due, so timer resolution is limited only by the OS, not by polling.
— Brazil