co_usb
Loading...
Searching...
No Matches
co_usb::ev::trivial_event_handler Struct Reference

Trivial single-threaded libusb event handler. More...

#include <handlers.hpp>

Public Member Functions

auto start (libusb_context *usb_ctx, std::stop_token stop) -> bool
 Start the libusb event processing loop.
 
auto ref () noexcept
 Increment internal reference count.
 
auto unref () noexcept
 Decrement internal reference count.
 
auto stop ()
 Stop the event loop and wait for the thread to finish.
 
 ~trivial_event_handler ()
 Stop the event thread on destruction.
 

Detailed Description

Trivial single-threaded libusb event handler.

This handler starts a background loop that repeatedly calls libusb_handle_events_timeout() until std::stop_token requests stop.

Constructor & Destructor Documentation

◆ ~trivial_event_handler()

co_usb::ev::trivial_event_handler::~trivial_event_handler ( )
inline

Stop the event thread on destruction.

Member Function Documentation

◆ ref()

auto co_usb::ev::trivial_event_handler::ref ( )
inlinenoexcept

Increment internal reference count.

This implementation is a no-op.

◆ start()

auto co_usb::ev::trivial_event_handler::start ( libusb_context *  usb_ctx,
std::stop_token  stop 
) -> bool
inline

Start the libusb event processing loop.

Parameters
usb_ctxlibusb context to handle events for.
stopStop token used to end the loop.
Returns
true on successful start.

◆ stop()

auto co_usb::ev::trivial_event_handler::stop ( )
inline

Stop the event loop and wait for the thread to finish.

Must block until handling is stopped.

◆ unref()

auto co_usb::ev::trivial_event_handler::unref ( )
inlinenoexcept

Decrement internal reference count.

This implementation is a no-op.


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