Dex.ThreadPoolScheduler

g Dex.Object Dex.Object Dex.Scheduler Dex.Scheduler Dex.Object->Dex.Scheduler Dex.ThreadPoolScheduler Dex.ThreadPoolScheduler Dex.Scheduler->Dex.ThreadPoolScheduler

Subclasses:

None

Methods

Inherited:

Dex.Scheduler (6), Dex.Object (2)

class

get_default ()

class

new ()

Virtual Methods

None

Fields

None

Class Details

class Dex.ThreadPoolScheduler
Bases:

Dex.Scheduler

Abstract:

No

DexThreadPoolScheduler is a [class`Dex`.Scheduler] that will dispatch work items and fibers to sub-schedulers on a specific operating system thread.

[class`Dex`.Fiber] will never migrate from the thread they are created on to reduce chances of safety issues involved in tracking state between CPU.

New work items are placed into a global work queue and then dispatched efficiently to a single thread pool worker using a specialized async semaphore. On modern Linux using io_uring, this wakes up a single worker thread and therefore is not subject to “thundering herd” common with global work queues.

When a worker creates a new work item, it is placed into a work stealing queue owned by the thread. Other worker threads may steal work items when they have exhausted their own work queue.

classmethod get_default()
Returns:

a [class`Dex`.Scheduler]

Return type:

Dex.Scheduler

Gets the default thread pool scheduler for the instance.

This function is useful to allow programs and libraries to share an off-main-thread scheduler without having to coordinate on where the scheduler instance is created or owned.

classmethod new()
Returns:

a [class`Dex`.ThreadPoolScheduler]

Return type:

Dex.Scheduler

Creates a new [class`Dex`.Scheduler] that executes work items on a thread pool.