Zth (libzth)
Loading...
Searching...
No Matches
zth::PollerClient Class Reference

The poller to be used by a fiber. More...

#include <poller.h>

Inheritance diagram for zth::PollerClient:
zth::PollerClientBase zth::PollerInterface zth::UniqueID< PollerInterface > zth::NamedUniqueID< Named > zth::UniqueIDBase

Public Types

typedef PollerClientBase base
 
typedef small_vector< Pollable * > Result
 Result of poll().
 
- Public Types inherited from zth::PollerClientBase
typedef small_vector< Pollable * > Result
 Result of poll().
 
- Public Types inherited from zth::UniqueID< PollerInterface >
typedef NamedUniqueID base
 

Public Member Functions

 PollerClient ()
 
 PollerClient (std::initializer_list< std::reference_wrapper< Pollable > > l)
 
virtual ~PollerClient () noexcept override
 
virtual void reserve (size_t more) override
 Reserve memory to add more pollables.
 
virtual int add (Pollable &p) noexcept override
 Add a pollable object.
 
virtual int remove (Pollable &p) noexcept override
 Remove a pollable object.
 
virtual Result const & poll (int timeout_ms=-1) noexcept override
 Poll.
 
virtual void event (Pollable &p) noexcept override
 Indicate that the given pollable got an event.
 
bool empty () const noexcept final
 Checks if there is any pollable registered.
 
- Public Member Functions inherited from zth::PollerClientBase
virtual ~PollerClientBase () noexcept override=default
 
- Public Member Functions inherited from zth::PollerInterface
virtual ~PollerInterface () noexcept override=default
 Dtor.
 
int add (std::initializer_list< std::reference_wrapper< Pollable > > l) noexcept
 Add pollable objects.
 
- 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 () noexcept override=default
 
void const * normptr () const noexcept
 
uint64_t id () const noexcept
 
- Public Member Functions inherited from zth::NamedUniqueID< Named >
virtual ~NamedUniqueID () noexcept override=default
 
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 noexcept override
 

Additional Inherited Members

- Static Public Member Functions inherited from zth::UniqueID< PollerInterface >
static uint64_t getID () noexcept
 
- Protected Member Functions inherited from zth::UniqueID< PollerInterface >
virtual uint64_t id_ () const noexcept final
 
- Protected Member Functions inherited from zth::NamedUniqueID< Named >
 NamedUniqueID (char const *name=nullptr)
 
 NamedUniqueID (string const &name)
 
 NamedUniqueID (string &&name)
 
- Protected Member Functions inherited from zth::UniqueIDBase
virtual ~UniqueIDBase () noexcept=default
 

Detailed Description

The poller to be used by a fiber.

All poll requests are forwarded to the PollerServer, as managed by the current Worker's zth::Waiter.

Definition at line 734 of file poller.h.

Member Typedef Documentation

◆ base

Definition at line 740 of file poller.h.

◆ Result

Result of poll().

Definition at line 244 of file poller.h.

Constructor & Destructor Documentation

◆ PollerClient() [1/2]

zth::PollerClient::PollerClient ( )

Definition at line 213 of file poller.cpp.

◆ PollerClient() [2/2]

zth::PollerClient::PollerClient ( std::initializer_list< std::reference_wrapper< Pollable > >  l)

Definition at line 219 of file poller.cpp.

◆ ~PollerClient()

zth::PollerClient::~PollerClient ( )
overridevirtualdefaultnoexcept

Member Function Documentation

◆ add()

int zth::PollerClient::add ( Pollable p)
overridevirtualnoexcept

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.

Definition at line 244 of file poller.cpp.

◆ empty()

bool zth::PollerClient::empty ( ) const
finalvirtualnoexcept

Checks if there is any pollable registered.

Implements zth::PollerInterface.

Definition at line 344 of file poller.cpp.

◆ event()

void zth::PollerClient::event ( Pollable p)
overridevirtualnoexcept

Indicate that the given pollable got an event.

Implements zth::PollerClientBase.

Definition at line 331 of file poller.cpp.

◆ poll()

PollerClient::Result const & zth::PollerClient::poll ( int  timeout_ms = -1)
overridevirtualnoexcept

Poll.

When timeout_ms is -1, poll() blocks until at least one of the pollables got an event. When timeout_ms is 0, poll() never blocks. Otherwise, poll() blocks at most for timeout_ms and return with a timeout, or return earlier when a pollable got an event.

Returns
The registered pollables that have an event set. If the result is empty, errno is set to the error.

Implements zth::PollerClientBase.

Definition at line 270 of file poller.cpp.

◆ remove()

int zth::PollerClient::remove ( Pollable p)
overridevirtualnoexcept

Remove a pollable object.

Returns
0 on success, otherwise an errno

Implements zth::PollerInterface.

Definition at line 256 of file poller.cpp.

◆ reserve()

void zth::PollerClient::reserve ( size_t  more)
overridevirtual

Reserve memory to add more pollables.

Exceptions
std::bad_allocwhen allocation fails

Implements zth::PollerInterface.

Definition at line 238 of file poller.cpp.


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