Zth (libzth)
Loading...
Searching...
No Matches
zth::PollerServerBase Class Referenceabstract

Abstract base class of a Poller server. More...

#include <poller.h>

Inheritance diagram for zth::PollerServerBase:
zth::PollerInterface zth::UniqueID< PollerInterface > zth::UniqueIDBase zth::PollerServer< zmq_pollitem_t > zth::PollerServer< PollItem_ > zth::ZmqPoller

Public Types

typedef PollerClientBase Client
 

Public Member Functions

virtual ~PollerServerBase () override=default
 
virtual int poll (int timeout_ms) noexcept=0
 Poll.
 
virtual int migrateTo (PollerServerBase &p) noexcept=0
 Move all registered Pollables to another server.
 
virtual int add (Pollable &p, Client *client) noexcept=0
 Add a Pollable, that belongs to a given client.
 
virtual int remove (Pollable &p, Client *client) noexcept=0
 Remove the given Pollable, belonging to the given client.
 
virtual int add (Pollable &p) noexcept=0
 Add a pollable object.
 
int add (std::initializer_list< std::reference_wrapper< Pollable > > l) noexcept
 Add pollable objects.
 
virtual int remove (Pollable &p) noexcept=0
 Remove a pollable object.
 
- Public Member Functions inherited from zth::PollerInterface
virtual ~PollerInterface () override=default
 Dtor.
 
int add (std::initializer_list< std::reference_wrapper< Pollable > > l) noexcept
 Add pollable objects.
 
virtual void reserve (size_t more)=0
 Reserve memory to add more pollables.
 
virtual bool empty () const noexcept=0
 Checks if there is any pollable registered.
 
- Public Member Functions inherited from zth::UniqueID< PollerInterface >
 UniqueID (UniqueID const &)=delete
 
 UniqueID (UniqueID &&u) noexcept
 
 UniqueID (string const &name)
 
 UniqueID (string &&name)
 
 UniqueID (char const *name=nullptr)
 
UniqueIDoperator= (UniqueID const &)=delete
 
UniqueIDoperator= (UniqueID &&u) noexcept
 
virtual ~UniqueID () override=default
 
void const * normptr () const noexcept
 
uint64_t id () const noexcept
 
string const & name () const noexcept
 
void setName (string const &name)
 
void setName (char const *name)
 
void setName (string &&name)
 
virtual char const * id_str () const override
 

Additional Inherited Members

- Static Public Member Functions inherited from zth::UniqueID< PollerInterface >
static uint64_t getID () noexcept
 
- Protected Member Functions inherited from zth::UniqueIDBase
virtual ~UniqueIDBase ()=default
 

Detailed Description

Abstract base class of a Poller server.

Definition at line 270 of file poller.h.

Member Typedef Documentation

◆ Client

Definition at line 272 of file poller.h.

Constructor & Destructor Documentation

◆ ~PollerServerBase()

virtual zth::PollerServerBase::~PollerServerBase ( )
overridevirtualdefault

Member Function Documentation

◆ add() [1/3]

virtual int zth::PollerInterface::add ( Pollable p)
virtualnoexcept

Add a pollable object.

Once a pollable is added, do not modify its properties, except for user_data.

Returns
0 on success, otherwise an errno

Implements zth::PollerInterface.

◆ add() [2/3]

virtual int zth::PollerServerBase::add ( Pollable p,
Client client 
)
pure virtualnoexcept

Add a Pollable, that belongs to a given client.

client can be nullptr.

Returns
0 on success, otherwise an errno

Implemented in zth::PollerServer< zmq_pollitem_t >, and zth::PollerServer< PollItem_ >.

◆ add() [3/3]

int zth::PollerInterface::add ( std::initializer_list< std::reference_wrapper< Pollable > >  l)
noexcept

Add pollable objects.

Returns
0 on success, otherwise an errno

Definition at line 206 of file poller.cpp.

◆ migrateTo()

virtual int zth::PollerServerBase::migrateTo ( PollerServerBase p)
pure virtualnoexcept

Move all registered Pollables to another server.

Returns
0 on success, otherwise an errno

Implemented in zth::PollerServer< zmq_pollitem_t >, and zth::PollerServer< PollItem_ >.

◆ poll()

virtual int zth::PollerServerBase::poll ( int  timeout_ms)
pure virtualnoexcept

Poll.

The Pollables with events are not saved in the server, but these are forwarded to the registered Client.

Returns
0 when a Pollable returned an event, otherwise an errno

Implemented in zth::PollerServer< zmq_pollitem_t >, and zth::PollerServer< PollItem_ >.

◆ remove() [1/2]

virtual int zth::PollerInterface::remove ( Pollable p)
virtualnoexcept

Remove a pollable object.

Returns
0 on success, otherwise an errno

Implements zth::PollerInterface.

◆ remove() [2/2]

virtual int zth::PollerServerBase::remove ( Pollable p,
Client client 
)
pure virtualnoexcept

Remove the given Pollable, belonging to the given client.

client must match the one that was specified during add().

Returns
0 on success, otherwise an errno

Implemented in zth::PollerServer< zmq_pollitem_t >, and zth::PollerServer< PollItem_ >.


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