Poller
Basically, these classes provide poll()
in a platform-independent way. To
use the poller, create one or more Pollables, and register them to the
stored::Poller
, and call its poll()
member function. It
returns a list of pollables that have an event to be processed.
The inheritance of the Poller classes is shown below.
Pollables
stored::Pollable
-
struct Pollable
A pollable thing.
Subclassed by stored::TypedPollable
Public Types
-
typedef unsigned long long Events_value
Public Functions
Public Members
Public Static Attributes
-
static Events_value const PollErr = 1UL << PollErrIndex
-
static Events_value const PollHup = 1UL << PollHupIndex
-
static Events_value const PollIn = 1UL << PollInIndex
-
static Events_value const PollOut = 1UL << PollOutIndex
-
static Events_value const PollPri = 1UL << PollPriIndex
-
typedef unsigned long long Events_value
stored::PollableCallback
-
template<typename F = Pollable::Events (*)(Pollable const&)>
class PollableCallback : public stored::PollableCallbackBase Use a callback function while polling.
The function type
F
must be compatible withPollable::Events& (Pollable const&)
.Public Functions
-
inline virtual Events operator()() const noexcept final
-
inline virtual Events operator()() const noexcept final
-
inline PollableCallback stored::pollable(PollableCallback<>::f_type f, Pollable::Events const &events, void *user = nullptr)
stored::PollableFd
-
class PollableFd : public stored::TypedPollable
Poll a file descriptor.
Do not use in Windows, as its file descriptors are not pollable.
Public Functions
-
inline constexpr PollableFd(int f, Events const &e, void *user = nullptr) noexcept
Public Members
-
int fd
-
inline constexpr PollableFd(int f, Events const &e, void *user = nullptr) noexcept
-
inline PollableFd stored::pollable(int fd, Pollable::Events const &events, void *user = nullptr)
stored::PollableFileLayer
-
class PollableFileLayer : public stored::TypedPollable
Poll a stored::PolledFileLayer.
Public Functions
-
inline constexpr PollableFileLayer(PolledFileLayer &l, Events const &e, void *user = nullptr) noexcept
Public Members
-
PolledFileLayer *layer
-
inline constexpr PollableFileLayer(PolledFileLayer &l, Events const &e, void *user = nullptr) noexcept
-
inline PollableFileLayer stored::pollable(PolledFileLayer &l, Pollable::Events const &events, void *user = nullptr)
stored::PollableHandle
stored::PollableSocket
-
class PollableSocket : public stored::TypedPollable
Poll a Windows SOCKET.
Public Functions
-
inline constexpr PollableSocket(SOCKET s, Events const &e, void *user = nullptr) noexcept
Public Members
-
SOCKET socket
-
inline constexpr PollableSocket(SOCKET s, Events const &e, void *user = nullptr) noexcept
-
inline PollableSocket stored::pollable(SOCKET s, Pollable::Events const &events, void *user = nullptr)
stored::PollableZmqLayer
-
class PollableZmqLayer : public stored::TypedPollable
Poll a stored::ZmqLayer.
Public Functions
-
inline constexpr PollableZmqLayer(ZmqLayer &l, Events const &e, void *user = nullptr) noexcept
Public Members
-
ZmqLayer *layer
-
inline constexpr PollableZmqLayer(ZmqLayer &l, Events const &e, void *user = nullptr) noexcept
-
inline PollableZmqLayer stored::pollable(ZmqLayer &l, Pollable::Events const &events, void *user = nullptr)
stored::PollableZmqSocket
-
class PollableZmqSocket : public stored::TypedPollable
Poll a ZeroMQ socket.
Public Functions
-
inline constexpr PollableZmqSocket(void *s, Events const &e, void *user = nullptr) noexcept
Public Members
-
void *socket
-
inline constexpr PollableZmqSocket(void *s, Events const &e, void *user = nullptr) noexcept
-
inline PollableZmqSocket stored::pollable(void *s, Pollable::Events const &events, void *user = nullptr)
stored::InheritablePoller
-
template<typename PollerImpl = PollerImpl>
class InheritablePoller : public stored::ZmqPoller Subclassed by stored::Poller
Public Functions
-
inline virtual ~InheritablePoller() override
Dtor.
-
inline virtual int add(Pollable &p) noexcept
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
-
inline virtual void clear() noexcept
-
inline bool empty() const noexcept
Checks if there is any pollable registered.
-
inline virtual int remove(Pollable &p) noexcept
Remove a pollable object.
- Returns:
0 on success, otherwise an errno
-
inline virtual void reserve(size_t more)
Reserve memory to add more pollables.
- Throws:
std::bad_alloc – when allocation fails
-
inline virtual ~InheritablePoller() override
stored::Poller
-
class Poller : public stored::InheritablePoller<>
Public Types
-
typedef InheritablePoller base
-
typedef InheritablePoller base