Dex.TaskGroup

g Dex.Future Dex.Future Dex.TaskGroup Dex.TaskGroup Dex.Future->Dex.TaskGroup Dex.Object Dex.Object Dex.Object->Dex.Future

Subclasses:

None

Methods

Inherited:

Dex.Future (56), Dex.Object (2)

class

new (flags)

add (future)

cancel ()

close ()

pop_thread_default ()

push_thread_default ()

Virtual Methods

None

Fields

None

Class Details

class Dex.TaskGroup
Bases:

Dex.Future

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 NULL to [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:

Dex.TaskGroup

add(future)
Parameters:

future (Dex.Future) – a [class`Dex`.Future]

Returns:

false if the group is closed or cancelled; otherwise true.

Return type:

bool

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:

Dex.Future

Close the group to new tasks.

Added in version 1.2.

pop_thread_default()
push_thread_default()