co_usb
Loading...
Searching...
No Matches
co_usb::transfer::detail::partial_io_base< TSeq > Struct Template Reference

Zero-allocation adapter around a transfer sequence enabling the use of asynchronous partial I/O operations on a given transfer sequence. More...

#include <partial_io.hpp>

Inheritance diagram for co_usb::transfer::detail::partial_io_base< TSeq >:
Collaboration diagram for co_usb::transfer::detail::partial_io_base< TSeq >:

Public Member Functions

 partial_io_base (boost::capy::executor_ref exec, TSeq const &tfer_seq)
 
template<detail::AnyBufferSequence BuffersTy>
auto submit (BuffersTy const &buffers) -> boost::capy::io_task< size_t >
 Submit a transfer sequence for a buffer sequence.
 

Protected Attributes

ev::event_handler_ref m_ev_ref
 
sequence_view< TSeq > m_view
 

Detailed Description

template<detail::TransferSequence TSeq>
struct co_usb::transfer::detail::partial_io_base< TSeq >

Zero-allocation adapter around a transfer sequence enabling the use of asynchronous partial I/O operations on a given transfer sequence.

Note
Handles cancellation.

This type is designed to be a barebones wrapper around raw machinery for tying asynchronous transfers into the coroutine ecosystem.

Transfer sequence lifetime guarantee

Transfer sequence is expected to outlive an instance of this type which uses it. Deallocating, modifying and replacing transfers while an asynchronous operation is pending is undefined behaviour unless it is a cancel_transfer call in which case the operation is well-defined and will cause this particular transfer to be cancelled and cause an error with transfer_status cancelled value.

Submission order

The submissions are done in a streaming manner, hence the name, where the N transfers from a sequence will be reused for M buffers, in an order in which the transfers complete. This allows to saturate the USB controller ring with large enough set of buffers. In practice, however, the amount of transfers provided has diminishing returns due to internal libusb mutex and ring oversaturation, and after a certain points using more transfers will be slower than using fewer.

Event handler guarantee

To prevent event handler from prematurely shutting down on stop request an event_handler_ref is held for the entire lifetime of an object of this type.

See also
co_usb::ev::event_handler_ref
co_usb::ev::detail::handler_service

Constructor & Destructor Documentation

◆ partial_io_base()

template<detail::TransferSequence TSeq>
co_usb::transfer::detail::partial_io_base< TSeq >::partial_io_base ( boost::capy::executor_ref  exec,
TSeq const &  tfer_seq 
)
inlineexplicit

Member Function Documentation

◆ submit()

template<detail::TransferSequence TSeq>
template<detail::AnyBufferSequence BuffersTy>
auto co_usb::transfer::detail::partial_io_base< TSeq >::submit ( BuffersTy const &  buffers) -> boost::capy::io_task<size_t>
inline

Submit a transfer sequence for a buffer sequence.

Returns
result of the operation

Member Data Documentation

◆ m_ev_ref

template<detail::TransferSequence TSeq>
ev::event_handler_ref co_usb::transfer::detail::partial_io_base< TSeq >::m_ev_ref
protected

◆ m_view

template<detail::TransferSequence TSeq>
sequence_view<TSeq> co_usb::transfer::detail::partial_io_base< TSeq >::m_view
protected

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