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

libusb event handler with simple internal reference counting. 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 the internal reference counter.
 
auto unref () noexcept
 Decrement the internal reference counter.
 
auto stop ()
 Stop the event loop and wait for the thread to finish.
 
 ~refcounted_event_handler ()
 Stop the event thread on destruction.
 

Detailed Description

libusb event handler with simple internal reference counting.

This implementation runs a background loop calling libusb_handle_events_timeout() until stop is requested and the internal counter reaches zero.

Constructor & Destructor Documentation

◆ ~refcounted_event_handler()

co_usb::ev::refcounted_event_handler::~refcounted_event_handler ( )
inline

Stop the event thread on destruction.

Member Function Documentation

◆ ref()

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

Increment the internal reference counter.

◆ start()

auto co_usb::ev::refcounted_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::refcounted_event_handler::stop ( )
inline

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

Blocks until handling is stopped.

◆ unref()

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

Decrement the internal reference counter.


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