23 lines
739 B
Plaintext
23 lines
739 B
Plaintext
:sig
|
|
pid_t task(String key, std::function<void()> exec_func)
|
|
|
|
:params
|
|
key : string uniquely identifying the task
|
|
exec_func : function to execute
|
|
return value : the process ID of the started (or still running) task
|
|
|
|
:see
|
|
>task
|
|
|
|
: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.
|
|
|
|
Use the `key` to make a background job idempotent across repeated calls.
|
|
|
|
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
|