Index wasi args_get args_sizes_get clock_res_get clock_time_get environ_get environ_sizes_get fd_advise fd_allocate fd_close fd_datasync fd_fdstat_get fd_fdstat_set_flags fd_fdstat_set_rights fd_filestat_get fd_filestat_set_size fd_filestat_set_times fd_pread fd_prestat_dir_name fd_prestat_get fd_pwrite fd_read fd_readdir fd_renumber fd_seek fd_sync fd_tell fd_write file_stat_flags filestat iovec lookup_flags path_create_directory path_filestat_get path_filestat_set_times path_link path_open path_readlink path_remove_directory path_rename path_symlink path_unlink_file poll_oneoff proc_exit proc_raise random_get sched_yield sock_accept sock_recv sock_send sock_shutdown
Concurrently poll for a set of events.
poll_oneoff (
in_: __wasi_subscription_tA wasm pointer to an array of `__wasi_subscription_t` structures representing the events to subscribe toout_: __wasi_event_tA wasm pointer to an array of `__wasi_event_t` structures where the occurred events will be storednsubscriptions: u32The number of subscriptions and the number of eventsnevents: u32A wasm pointer to a `u32` variable that will store the number of events seen
) =>
error: i32 

The poll_oneoff() function allows concurrent polling for a set of events. It takes an array of event subscriptions and returns the events that have occurred since the last poll. It is instrumented with trace level logging for debugging purposes.

On POSIX systems, a similar functionality is provided by the poll() function. It allows monitoring multiple file descriptors for various types of events, such as read or write readiness, error conditions, or hang-up events. The poll() function is part of the POSIX standard and is widely supported across different platforms.

Note

The poll_oneoff() function enables concurrent polling for a set of events. It internally uses the poll_oneoff_internal() function to perform the actual polling operation.

The function first processes any pending signals and exits if necessary. It then increments the poll seed to ensure different event ordering in subsequent calls.

Next, it retrieves the event subscriptions from the input array and creates a list of subscription objects. Each subscription object represents an event subscription.

The function clears the number of events to prepare for the upcoming polling.

Read More