Zth (libzth)
|
Poller to be executed by the Waiter. More...
#include <poller.h>
Public Types | |
typedef PollerServerBase | base |
typedef PollerClientBase | Client |
Public Types inherited from zth::PollerServerBase | |
typedef PollerClientBase | Client |
Public Member Functions | |
PollerServer ()=default | |
Ctor. More... | |
PollerServer (PollerServer const &)=delete | |
void | operator= (PollerServer const &)=delete |
PollerServer (PollerServer &&p)=delete | |
void | operator= (PollerServer &&p)=delete |
virtual | ~PollerServer () override |
virtual int | migrateTo (PollerServerBase &p) noexcept override |
Move all registered Pollables to another server. More... | |
virtual void | reserve (size_t more) override |
Reserve memory to add more pollables. More... | |
int | add (Pollable &p, Client *client) noexcept final |
Add a Pollable, that belongs to a given client. More... | |
int | add (Pollable &p) noexcept final |
Add a pollable object. More... | |
int | remove (Pollable &p, Client *client) noexcept final |
Remove the given Pollable, belonging to the given client. More... | |
void | remove (size_t last) noexcept |
Remove the last added Pollables. More... | |
int | remove (Pollable &p) noexcept final |
Remove a pollable object. More... | |
void | clear () noexcept |
Clear all Pollables. More... | |
bool | empty () const noexcept final |
Checks if there is any pollable registered. More... | |
virtual int | poll (int timeout_ms) noexcept override |
Poll. More... | |
Public Member Functions inherited from zth::PollerServerBase | |
virtual | ~PollerServerBase () override=default |
Public Member Functions inherited from zth::PollerInterface | |
virtual | ~PollerInterface ()=default |
Dtor. More... | |
int | add (std::initializer_list< std::reference_wrapper< Pollable >> l) noexcept |
Add pollable objects. More... | |
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) | |
UniqueID & | operator= (UniqueID const &)=delete |
UniqueID & | operator= (UniqueID &&u) noexcept |
virtual | ~UniqueID ()=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 |
Protected Types | |
typedef PollItem_ | PollItem |
typedef small_vector< PollItem, 4 > | PollItemList |
Type of list of poll things. More... | |
Protected Member Functions | |
void | event (Pollable::Events revents, size_t index) noexcept |
Register an revents for the PollItem at the given index. More... | |
Protected Member Functions inherited from zth::UniqueIDBase | |
virtual | ~UniqueIDBase ()=default |
Additional Inherited Members | |
Static Public Member Functions inherited from zth::UniqueID< PollerInterface > | |
static uint64_t | getID () noexcept |
Poller to be executed by the Waiter.
Per-fiber Poller clients can forward their poll request to the server.
poll
() typically uses an array of things to do the actual poll on, such as struct
pollfd
. This class manages the administration of Pollables to these things.
The subclass must implement init()
to initialize this thing, and doPoll()
to perform the actual poll. Implement deinit()
to do cleanup of that thing before destruction.
PollItem_ | the item to be used as the actual poll thing |
typedef PollerServerBase zth::PollerServer< PollItem_ >::base |
typedef PollerClientBase zth::PollerServerBase::Client |
|
protected |
|
protected |
|
default |
Ctor.
|
delete |
|
delete |
|
inlineoverridevirtual |
|
inlinefinalvirtualnoexcept |
Add a pollable object.
Once a pollable is added, do not modify its properties, except for user_data
.
Implements zth::PollerInterface.
|
inlinefinalvirtualnoexcept |
Add a Pollable, that belongs to a given client.
client
can be nullptr
.
Implements zth::PollerServerBase.
|
inlinenoexcept |
|
inlinefinalvirtualnoexcept |
Checks if there is any pollable registered.
Implements zth::PollerInterface.
|
inlineprotectednoexcept |
|
inlineoverridevirtualnoexcept |
Move all registered Pollables to another server.
Implements zth::PollerServerBase.
|
delete |
|
delete |
|
inlineoverridevirtualnoexcept |
Poll.
The Pollables with events are not saved in the server, but these are forwarded to the registered Client.
Implements zth::PollerServerBase.
|
inlinefinalvirtualnoexcept |
|
inlinefinalvirtualnoexcept |
Remove the given Pollable, belonging to the given client.
client
must match the one that was specified during add().
Implements zth::PollerServerBase.
|
inlinenoexcept |
|
inlineoverridevirtual |
Reserve memory to add more pollables.
std::bad_alloc | when allocation fails |
Implements zth::PollerInterface.