Add archive helpers and harden task runtime

This commit is contained in:
udo
2026-05-21 00:00:23 +00:00
parent 9f7625c7fd
commit 02e153a6a7
71 changed files with 12817 additions and 305 deletions
+11 -5
View File
@@ -1,20 +1,26 @@
:sig
pid_t task(String key, std::function<void()> exec_func)
pid_t task(String key, std::function<void()> exec_func, u64 timeout = 60*10)
:params
key : string uniquely identifying the task
key : string uniquely identifying the task across the whole runtime instance
exec_func : function to execute
return value : the process ID of the started (or still running) task
timeout : maximum run time in seconds; `0` disables the timeout
return value : the process ID of the started (or still running) task, or `0` when the task could not be started
:see
>task
task_pid
task_kill
task_repeat
:content
Starts `exec_func` in a new process and returns that process ID.
If a process with the same `key` is already running, `task()` does not start a second copy. Instead it returns the PID of the already-running task.
If a process with the same `key` is already running anywhere in the runtime instance, `task()` does not start a second copy. Instead it returns the PID of the already-running task. Coordination is through a shared task status file under `BIN_DIRECTORY`, so the key applies across workers, not just the current worker process.
Use the `key` to make a background job idempotent across repeated calls.
Task keys may contain ordinary user-facing text. UCE hashes the key before using it as an internal lock/status filename so slashes and other path-like characters cannot escape the task state directory.
`timeout` is enforced in the child process with an alarm. The default is ten minutes. Pass `0` only for tasks that are intentionally unbounded and have their own shutdown path.
Related: