tur/taskgroup
task-group-new
(task-group-new :ptr<void>)
create a new empty TaskGroup.
Since: Phase T22
fiber-cancelled?
(fiber-cancelled? :bool)
check whether the current fiber has been cancelled.
Since: Phase T22
task-group-cancelled?
(task-group-cancelled? [group :ptr<void>] :bool)
check whether a specific task group has been cancelled.
| group | task group handle returned by task-group-new |
Since: Phase T22
task-group-should-exit?
(task-group-should-exit? [group :ptr<void>] :bool)
return true if the current task should stop, checking both fiber and group cancellation.
| group | task group handle returned by task-group-new |
Since: Phase T22
fiber-should-exit?
(fiber-should-exit? :bool)
check whether the current fiber should exit (without group context).
Since: Phase T22
task-group-done?
(task-group-done? [group :ptr<void>] :bool)
check whether all tasks in the group have completed.
| group | task group handle returned by task-group-new |
Since: Phase T22
task-group-task-done
(task-group-task-done [group :ptr<void>] :nil)
signal that the calling task has completed; must be called by each spawned task.
| group | task group handle returned by task-group-new |
Since: Phase T22
task-group-wait
(task-group-wait [group :ptr<void>] :nil)
block until all tasks in the group have completed.
| group | task group handle returned by task-group-new |
Since: Phase T22
task-group-cancel
(task-group-cancel [group :ptr<void>] :nil)
cooperatively cancel all tasks in the group (reason: manual).
| group | task group handle returned by task-group-new |
Since: Phase T22
task-group-cancel-with-reason
(task-group-cancel-with-reason [group :ptr<void> reason :int] :nil)
cancel all tasks in the group with a specific reason code.
| group | task group handle returned by task-group-new | |
| reason | cancel reason: 0=manual, 1=panic, 2=timeout, 3=error |
Since: Phase T22
task-group-cancel-panic
(task-group-cancel-panic [group :ptr<void>] :nil)
cancel the group with reason 1 (panic).
| group | task group handle returned by task-group-new |
Since: Phase T22
task-group-cancel-timeout
(task-group-cancel-timeout [group :ptr<void>] :nil)
cancel the group with reason 2 (timeout).
| group | task group handle returned by task-group-new |
Since: Phase T22
task-group-cancel-error
(task-group-cancel-error [group :ptr<void>] :nil)
cancel the group with reason 3 (error).
| group | task group handle returned by task-group-new |
Since: Phase T22
task-group-cancel-reason
(task-group-cancel-reason [group :ptr<void>] :int)
return the reason code why the group was cancelled.
| group | task group handle returned by task-group-new |
Since: Phase T22
task-group-spawn
(task-group-spawn [group :ptr<void> f :ptr<void>] :ptr<void>)
spawn a fiber into the task group and return its handle.
| group | task group handle returned by task-group-new | |
| f | zero-argument fiber entry-point function pointer |
Since: Phase T22
task-group-join
(task-group-join [group :ptr<void> handle :ptr<void>] :nil)
wait for a specific spawned fiber to complete.
| group | task group handle returned by task-group-new | |
| handle | fiber handle returned by task-group-spawn |
Since: Phase T22
task-handle-done?
(task-handle-done? [handle :ptr<void>] :bool)
non-blocking check whether a specific spawned fiber has completed.
| handle | fiber handle returned by task-group-spawn |
Since: Phase T22
task-group-free
(task-group-free [group :ptr<void>] :nil)
destroy a task group and release its memory.
| group | task group handle returned by task-group-new |
Since: Phase T22
task-group-with
(task-group-with [group & body])
task-group-with-timeout
(task-group-with-timeout [group ms & body])
spawn-timeout-thread
(spawn-timeout-thread [group :ptr<void> ms :int] :ptr<void>)
spawn a background thread that cancels the group after ms milliseconds.
| group | task group handle returned by task-group-new | |
| ms | delay in milliseconds before the group is cancelled |
Since: Phase T22
join-timeout-thread
(join-timeout-thread [t :ptr<void>] :nil)
free the handle of a detached timeout thread.
| t | thread handle returned by spawn-timeout-thread |
Since: Phase T22
task-group-with-cancellation
(task-group-with-cancellation [group & body])
task-group-spawn-async
(task-group-spawn-async [group :ptr<void> f :ptr<void>] :ptr<void>)
spawn an async computation into a task group and return a Future.
| group | task group handle returned by task-group-new | |
| f | no-argument function returning int64_t to run as a fiber |
Since: Phase T22
task-group-async
(task-group-async [group async-thunk])
Internal definitions
__fiber_set_cancelled-- set the current fiber's cancelled flag (internal use only).__tg-async-entry-- internal fiber entry point for task-group-spawn-async (internal use only).