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

Awaitable for submitting transfers. More...

#include <transfer_awaitable.hpp>

Collaboration diagram for co_usb::transfer_awaitable:
Collaboration graph
[legend]

Classes

struct  cb_data
 

Public Member Functions

 transfer_awaitable (libusb_transfer *tfer) noexcept
 
bool await_ready () noexcept
 
std::coroutine_handle await_suspend (std::coroutine_handle<> h, boost::capy::io_env const *env)
 suspends and submits the transfer
 
boost::capy::io_result< size_tawait_resume ()
 returns the result of a tranfer as an std::error_code and size of transfer's buffer contents after the operation.
 

Public Attributes

libusb_transfertransfer = nullptr
 
struct co_usb::transfer_awaitable::cb_data m_data
 

Detailed Description

Awaitable for submitting transfers.

Note
This class does NOT allocate at all

This is the lowest possible representation level of an asynchronous unit of libusb. It does not care for any of a transfer's properties and does not have direction- or transfer type-related bevahioral differences.

You should use this awaitable for porting an existing codebase to co_usb or when you need ultimate control.

Note
user_data and callback fields of a transfer object ARE OVERRIDDEN on await_suspend with internal coroutine machinery, to access data from a completed transfer consider inspecting the transfer object after the completion of the awaitable.

Constructor & Destructor Documentation

◆ transfer_awaitable()

co_usb::transfer_awaitable::transfer_awaitable ( libusb_transfer tfer)
noexcept

Member Function Documentation

◆ await_ready()

bool co_usb::transfer_awaitable::await_ready ( )
noexcept
Returns
always false, a transfer cannot be completed without roundtrip.

◆ await_resume()

boost::capy::io_result< size_t > co_usb::transfer_awaitable::await_resume ( )

returns the result of a tranfer as an std::error_code and size of transfer's buffer contents after the operation.

◆ await_suspend()

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

suspends and submits the transfer

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

◆ m_data

struct co_usb::transfer_awaitable::cb_data co_usb::transfer_awaitable::m_data

◆ transfer

libusb_transfer* co_usb::transfer_awaitable::transfer = nullptr

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