Dex.Scheduler

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

Subclasses:

Dex.MainScheduler, Dex.ThreadPoolScheduler

Methods

Inherited:

Dex.Object (2)

class

get_default ()

class

get_thread_default ()

class

ref_thread_default ()

get_main_context ()

push (func, *func_data)

spawn (stack_size, *func_data)

Virtual Methods

None

Fields

None

Class Details

class Dex.Scheduler
Bases:

Dex.Object

Abstract:

Yes

Dex.Scheduler is the base class used by schedulers.

Schedulers are responsible for ensuring asynchronous IO requests and completions are processed. They also schedule closures to be run as part of future result propagation. Additionally, they manage Dex.Fiber execution and suspension.

Specialized schedulers such as Dex.ThreadPoolScheduler will do this for a number of threads and dispatch new work between them.

classmethod get_default()
Returns:

a Dex.Scheduler

Return type:

Dex.Scheduler

Gets the default scheduler for the process.

The default scheduler executes tasks within the default GLib.MainContext. Typically that is the main thread of the application.

classmethod get_thread_default()
Returns:

a Dex.Scheduler or None

Return type:

Dex.Scheduler or None

Gets the default scheduler for the thread.

classmethod ref_thread_default()
Returns:

a Dex.Scheduler or None

Return type:

Dex.Scheduler or None

Gets the thread default scheduler with the reference count incremented.

get_main_context()
Returns:

a GLib.MainContext

Return type:

GLib.MainContext

Gets the default main context for a scheduler.

This may be a different value depending on the calling thread.

For example, calling this on the #DexThreadPoolScheduer from outside a worker thread may result in getting a shared GLib.MainContext for the process.

However, calling from a worker thread may give you a GLib.MainContext specifically for that thread.

push(func, *func_data)
Parameters:

Queues func to run on self.

spawn(stack_size, *func_data)
Parameters:
  • stack_size (int) – stack size in bytes or 0

  • func_data (object or None) – closure data for func

Returns:

a Dex.Future that will resolve or reject when func completes (or it’s resulting Dex.Future completes).

Return type:

Dex.Future

Request self to spawn a Dex.Fiber.

The fiber will have it’s own stack and cooperatively schedules among other fibers sharing the schaeduler.

If stack_size is 0, it will set to a sensible default. Otherwise, it is rounded up to the nearest page size.