co_usb
Loading...
Searching...
No Matches
co_usb::hotplug::detail::hotplug_awaitable Struct Reference

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

#include <hotplug_awaitable.hpp>

Collaboration diagram for co_usb::hotplug::detail::hotplug_awaitable:

Classes

struct  op_result
 
struct  resumption_t
 

Public Member Functions

 hotplug_awaitable (libusb_context *ctx, libusb_hotplug_callback_handle *handle, op_result *op_res, resumption_t *res, 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< event_type, device_refawait_resume ()
 

Public Attributes

libusb_context * ctx
 
libusb_hotplug_callback_handle * handle
 
op_resultop_res
 
resumption_tres
 
int events
 
int flags
 
int vid
 
int pid
 
int dev_class
 

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::detail::hotplug_awaitable::hotplug_awaitable ( libusb_context *  ctx,
libusb_hotplug_callback_handle *  handle,
op_result op_res,
resumption_t res,
int  events,
int  flags,
int  vid,
int  pid,
int  dev_class 
)
inline

Member Function Documentation

◆ await_ready()

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

◆ await_resume()

boost::capy::io_result< event_type, device_ref > co_usb::hotplug::detail::hotplug_awaitable::await_resume ( )
inline

◆ await_suspend()

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

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

Member Data Documentation

◆ ctx

libusb_context* co_usb::hotplug::detail::hotplug_awaitable::ctx

◆ dev_class

int co_usb::hotplug::detail::hotplug_awaitable::dev_class

◆ events

int co_usb::hotplug::detail::hotplug_awaitable::events

◆ flags

int co_usb::hotplug::detail::hotplug_awaitable::flags

◆ handle

libusb_hotplug_callback_handle* co_usb::hotplug::detail::hotplug_awaitable::handle

◆ op_res

op_result* co_usb::hotplug::detail::hotplug_awaitable::op_res

◆ pid

int co_usb::hotplug::detail::hotplug_awaitable::pid

◆ res

resumption_t* co_usb::hotplug::detail::hotplug_awaitable::res

◆ vid

int co_usb::hotplug::detail::hotplug_awaitable::vid

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