co_usb
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
co_usb::hotplug_awaitable Struct Reference

Low-level awaitable primitive for strapping hotplug callbacks to a coroutine ecosystem. More...

#include <hotplug_awaitable.hpp>

Public Member Functions

 hotplug_awaitable (libusb_context *ctx, int events, int flags, int vid, int pid, int dev_class)
 
bool await_ready () noexcept
 
std::coroutine_handle await_suspend (std::coroutine_handle<> h, boost::capy::io_env const *env)
 suspends and registers the callback
 
boost::capy::io_result< hotplug_event, device_refawait_resume ()
 

Detailed Description

Low-level awaitable primitive for strapping hotplug callbacks to a coroutine ecosystem.

This is the lowest possible layer of abstraction over libusb's hotplug API. It should be used for maximum flexibility or when the behaviour of device_acceptor is unacceptable, e.g. when no heap allocation is acceptable.

Objects of this type are copyable since an awaitable object itself does not own any resource and operates on handles, pointers and integers instead. It it safe to copy and to move in any state.

Note
Does not allocate.

Constructor & Destructor Documentation

◆ hotplug_awaitable()

co_usb::hotplug_awaitable::hotplug_awaitable ( libusb_context ctx,
int  events,
int  flags,
int  vid,
int  pid,
int  dev_class 
)

Member Function Documentation

◆ await_ready()

bool co_usb::hotplug_awaitable::await_ready ( )
noexcept
Returns
always false, a hotplug cannot complete instantly without a roundtrip

◆ await_resume()

boost::capy::io_result< co_usb::hotplug_event, co_usb::device_ref > co_usb::hotplug_awaitable::await_resume ( )

◆ await_suspend()

std::coroutine_handle co_usb::hotplug_awaitable::await_suspend ( std::coroutine_handle<>  h,
boost::capy::io_env const env 
)

suspends and registers the callback

Parameters
hstd::coroutine_handle to the awaiting coroutine
envboost::capy::io_env* as per boost::capy::IoAwaitable concept
Returns
std::noop_coroutine on success
h on submission error or on cancellation

The documentation for this struct was generated from the following files: