uce/site/doc/pages/task_repeat.txt

25 lines
870 B
Plaintext

:sig
pid_t task_repeat(String key, f64 interval, std::function<void()> exec_func, u64 timeout = 60*10)
:params
key : string uniquely identifying the task
interval : repeat interval in seconds
exec_func : function to execute repeatedly
timeout : optional task timeout value
return value : the process ID of the started (or still running) task
:see
>task
:content
Starts a repeating background worker process.
`exec_func` runs in a loop, and the worker sleeps for `interval` seconds between executions.
If a process with the same `key` is already running, `task_repeat()` does not start a second worker and instead returns the PID of the existing one.
Related:
- PHP: background-process patterns using `proc_open()`, queues, cron, or worker supervisors
- JavaScript / Node.js: Node `child_process`, worker queues, timers, schedulers, and supervised background jobs