qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::io::async::base< _Derived, _EV_EVENT > Class Template Reference

Base class for all qb-io asynchronous components that interact with the event listener. More...

#include <io.h>

Protected Member Functions

 base ()
 Constructor that registers the event watcher with the current listener.
 ~base ()
 Destructor that unregisters the event watcher.

Protected Attributes

_EV_EVENT & _async_event
 Reference to the registered libev-based event watcher.

Detailed Description

template<typename _Derived, typename _EV_EVENT>
class qb::io::async::base< _Derived, _EV_EVENT >

Base class for all qb-io asynchronous components that interact with the event listener.

This template class provides the foundational mechanism for registering and unregistering a specific libev event watcher (represented by _EV_EVENT) with the thread-local qb::io::async::listener::current. Derived classes (using CRTP via _Derived) will typically inherit from this to manage their primary event watcher.

Template Parameters
_DerivedThe derived class type (CRTP pattern).
_EV_EVENTThe specific qb::io::async::event::* type (which wraps a libev watcher, e.g., event::io, event::timer).

Constructor & Destructor Documentation

◆ base()

template<typename _Derived, typename _EV_EVENT>
qb::io::async::base< _Derived, _EV_EVENT >::base ( )
inlineprotected

Constructor that registers the event watcher with the current listener.

The _async_event member is initialized by calling listener::current.registerEvent, associating the derived class instance (Derived) as the handler for this event type.

◆ ~base()

template<typename _Derived, typename _EV_EVENT>
qb::io::async::base< _Derived, _EV_EVENT >::~base ( )
inlineprotected

Destructor that unregisters the event watcher.

Stops the event watcher and unregisters it from the listener to prevent dangling references and ensure proper cleanup of libev resources. Specifically, it calls _async_event.stop() and then listener::current.unregisterEvent(_async_event._interface).