openusb_wait, openusb_poll

OpenUSB Developers Guide
Prev |  | Next

# `openusb_wait, openusb_poll`

## Name

`openusb_wait, openusb_poll` -- Wait for I/O request completion, Poll completion status of I/O request

## Synopsis

``int32_t openusb_wait`(uint32_t num_reqs, openusb_request_handle_t* handles, openusb_request_handle_t* handle);`

``int32_topenusb_poll`(uint32_t num_reqs, openusb_request_handle_t* handles, openusb_request_handle_t* handle);`

## Parameters

`num_reqs` Number of requests to wait/poll.

`handles` Array of request handles to wait/poll.

`handle` Completed request handle.

## Description

`openusb_wait()` can be called to wait for completion on `num_reqs` of request handles. If one request was completed, `openusb_wait` will return its handle in `handle`. Otherwise, `openusb_wait` will block until one request gets completed.

`openusb_poll()` is different from `openusb_wait`. It checks if any request in `handles` has been completed. If there's one, `openusb_poll` will return this request's handle in `handle`. Otherwise, it returns immediately with `handle` set to NULL. No block at all.

For both functions, caller should allocate an array of `num_reqs` elements for `handles` and set every element to the request handles to be checked.

If application has set callback in request when submitting it in `openusb_xfer_aio` , it should NOT call the above functions to wait/poll that request.

## Return Value

`openusb_wait`(), `openusb_poll`() returns 0 on success. Otherwise, a openusb error is returned.

OPENUSB_SUCCESS No errors.

OPENUSB_BADARG `handles` or `handle` is not valid. Either they are NULL or some member of request is invalid.

OPENUSB_UNKNOWN_DEVICE Can't find the device specified in request.

OPENUSB_PLATFORM_FAILURE Unspecified kernel/driver failure

OPENUSB_NO_RESOURCES Memory allocation failure

OPENUSB_IO_* USB host controller errors

## See Also

Prev | Home | Next
`openusb_abort` | Up | `openusb_start, openusb_stop`