Callbacks

FiberFunc (*user_data)

FutureCallback (future, *user_data)

SchedulerFunc (*user_data)

Details

Dex.FiberFunc(*user_data)
Parameters:

user_data (object or None) –

Returns:

a Dex.Future or None

Return type:

Dex.Future or None

This function prototype is used for spawning fibers. A fiber is a lightweight, cooperative-multitasking feature where the fiber is given it’s own stack. The fiber runs until it reaches a point of suspension (using dex_await or similar) or exits the fiber.

When suspended, the fiber is placed onto a queue until it is runnable again. Once runnable, the fiber is scheduled to run from within whatever scheduler it was created with.

See dex_scheduler_spawn()

Dex.FutureCallback(future, *user_data)
Parameters:
Returns:

a Dex.Future or None

Return type:

Dex.Future or None

A Dex.FutureCallback can be executed from a Dex.Block as response to another Dex.Future resolving or rejecting.

The callback will be executed within the scheduler environment the block is created within when using Dex.Future.then(), Dex.Future.catch(), Dex.Future.finally_(), Dex.Future.all(), and similar functions.

This is the expected way to handle completion of a future when not using Dex.Fiber via Dex.Scheduler.spawn().

Dex.SchedulerFunc(*user_data)
Parameters:

user_data (object or None) –