pub type fdf_dispatcher_t = fdf_dispatcher;Expand description
Dispatcher for performing asynchronous operations.
|fdf_dispatcher_t| can be used in conjunction with a |fdf_channel_t| to initiate asynchronous read operations. The dispatcher is in charge of dispatching the read callbacks.
§Thread safety
Operations on dispatcher objects are thread-safe.
§Example
void shutdown_handler(fdf_dispatcher_t* dispatcher, fdf_dispatcher_shutdown_observer_t* fdf_observer) { // Handle dispatcher shutdown. // It is now safe to destroy |dispatcher|. }
struct dispatcher_shutdown_observer { fdf_dispatcher_shutdown_observer_t fdf_observer; my_ctx* ctx; };
void driver_start(void) { const char* name = “my_driver”; const char* scheduler_role = “”; struct dispatcher_shutdown_observer my_observer; my_observer.fdf_observer.handler = shutdown_handler; …
fdf_dispatcher_t* dispatcher;
zx_status_t status = fdf_dispatcher_create(0, name, strlen(name),
scheduler_role, strlen(scheduler_role),
&my_observer.fdf_observer, &dispatcher);
fdf_channel_read_t channel_read;
...
status = fdf_channel_wait_async(dispatcher, channel_read, 0);
// The dispatcher will call the channel_read handler when ready.
// This begins the dispatcher shutdown process.
fdf_dispatcher_shutdown_async(dispatcher);}
Aliased Type§
pub struct fdf_dispatcher_t { /* private fields */ }