Skip to main content

fdf_dispatcher_create

Function fdf_dispatcher_create 

Source
pub unsafe extern "C" fn fdf_dispatcher_create(
    options: u32,
    name: *const c_char,
    name_len: usize,
    scheduler_role: *const c_char,
    scheduler_role_len: usize,
    observer: *mut fdf_dispatcher_shutdown_observer_t,
    out_dispatcher: *mut *mut fdf_dispatcher_t,
) -> zx_status_t
Expand description

Creates a dispatcher for performing asynchronous operations.

|options| provides the dispatcher configuration. The following options are supported:

  • FDF_DISPATHER_OPTION_SYNCHRONIZED or FDF_DISPATCHER_OPTION_UNSYNCHRONIZED - sets whether parallel callbacks in the callbacks set in the dispatcher are allowed.
  • FDF_DISPATCHER_OPTION_ALLOW_SYNC_CALLS - the dispatcher may not share zircon threads with other drivers. This may not be set with FDF_DISPATCHER_OPTION_UNSYNCHRONIZED or on a scheduler role that has FDF_SCHEDULER_ROLE_OPTION_NO_SYNC_CALLS set on it.

|name| is reported via diagnostics. It is similar to setting the name of a thread. |name_len| is the length of the string, without including the terminated NULL character. If |name| is greater than ZX_MAX_NAME_LEN, the length may be truncated.

|scheduler_role| is a hint. It may or not impact the priority the work scheduler against the dispatcher is handled at. It may or may not impact the ability for other drivers to share zircon threads with the dispatcher. |scheduler_role_len | is the length of the string, without including the terminating NULL character.

|observer| will be called after |fdf_dispatcher_shutdown_async| has been called, and the dispatcher has completed its asynchronous shutdown.

§Thread requirements

This must be called from a thread managed by the driver runtime.

§Errors

ZX_ERR_NOT_SUPPORTED: |options| is not a supported configuration, which is any of the following:

  • FDF_DISPATCHER_OPTION_UNSYNCHRONIZED with FDF_DISPATCHER_OPTION_ALLOW_SYNC_CALLS.

ZX_ERR_INVALID_ARGS: This was not called from a thread managed by the driver runtime.

ZX_ERR_NO_RESOURCES: A thread needed to be spawned to create this dispatcher, but couldn’t be. This is likely because a dispatcher that allows sync calls was requested, but the thread pool is currently at its limit.

ZX_ERR_BAD_STATE: Dispatchers are currently not allowed to be created, such as when a driver is being shutdown by its driver host.