Dex.TaskGroup¶
- Subclasses:
None
Methods¶
- Inherited:
class |
|
|
|
|
|
|
|
Virtual Methods¶
None
Fields¶
None
Class Details¶
- class Dex.TaskGroup¶
- Bases:
- Abstract:
No
A structured scope for related [class`Dex`.Future] instances.
A task group owns the futures added to it until the group is closed or cancelled. The group itself is also a [class`Dex`.Future], so callers can await the scope to learn when all tracked futures have finished.
Use [method`Dex`.TaskGroup.add] to attach futures explicitly, or pass
NULLto [method`Dex`.TaskGroup.add] after pushing a thread-default group with [method`Dex`.TaskGroup.push_thread_default]. Close the group with [method`Dex`.TaskGroup.close] once no more futures will be added.Cancellation is stronger than ordinary discard-driven cleanup: calling [method`Dex`.TaskGroup.cancel] cancels all tracked children, including nested task groups, and completes the task group with a cancellation error. When [method`Dex`.TaskGroup.close] is used instead, the task group resolves only after every tracked future has resolved or rejected.
Developer note: always pair [method`Dex`.TaskGroup.push_thread_default] with [method`Dex`.TaskGroup.pop_thread_default] on the same thread, and prefer [method`Dex`.TaskGroup.close] over relying on finalization to finish work.
Added in version 1.2.
- classmethod new(flags)¶
- Parameters:
flags (
Dex.TaskGroupFlags)- Return type:
- add(future)¶
- Parameters:
future (
Dex.Future) – a [class`Dex`.Future]- Returns:
falseif the group is closed or cancelled; otherwisetrue.- Return type:
Adds future to self.
If self is
null, then the future will be disowned. Otherwise, future will be added to self.Added in version 1.2.
- cancel()¶
- close()¶
- Returns:
a [class`Dex`.Future] that resolves when all the collected futures have resolved or rejected.
- Return type:
Close the group to new tasks.
Added in version 1.2.
- pop_thread_default()¶
- push_thread_default()¶