RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Types | Public Member Functions | Public Attributes
Datacratic::Epoller Struct Reference

#include <epoller.h>

Inheritance diagram for Datacratic::Epoller:
Datacratic::AsyncEventSource Datacratic::EndpointBase Datacratic::MessageLoop Datacratic::ActiveEndpoint Datacratic::PassiveEndpoint Datacratic::EndpointConnector Datacratic::Launcher::Service Datacratic::RestProxy Datacratic::RestServiceEndpoint Datacratic::ServiceProviderWatcher Datacratic::ZmqMultipleNamedClientBusProxy Datacratic::ZmqNamedEndpoint Datacratic::ZmqNamedMultipleSubscriber Datacratic::ZmqNamedProxy Datacratic::ZmqNamedPublisher Datacratic::ZmqNamedSocket RTBKIT::AgentConfigurationListener RTBKIT::AugmentationLoop RTBKIT::Augmentor RTBKIT::BiddingAgent

List of all members.

Public Types

typedef std::function< bool(epoll_event
&event)> 
HandleEvent
typedef std::function< void()> OnEvent

Public Member Functions

void init (int maxFds)
void close ()
void addFd (int fd, void *data=0)
void addFdOneShot (int fd, void *data=0)
void restartFdOneShot (int fd, void *data=0)
void removeFd (int fd)
int handleEvents (int usToWait=0, int nEvents=1, const HandleEvent &handleEvent=HandleEvent(), const OnEvent &beforeSleep=OnEvent(), const OnEvent &afterSleep=OnEvent())
virtual int selectFd () const
virtual bool poll () const
virtual bool processOne ()

Public Attributes

HandleEvent handleEvent
OnEvent beforeSleep
OnEvent afterSleep

Detailed Description

Basic wrapper around the epoll interface to turn it into an async event source.

Definition at line 26 of file epoller.h.


Member Function Documentation

void Datacratic::Epoller::addFd ( int  fd,
void *  data = 0 
)

Add the given fd to multiplex fd. It will repeatedly wake up the loop without being restarted.

Definition at line 65 of file epoller.cc.

void Datacratic::Epoller::addFdOneShot ( int  fd,
void *  data = 0 
)

Add the given fd to wake up one a one-shot basis. It will need to be restarted once the event is handled.

Definition at line 79 of file epoller.cc.

int Datacratic::Epoller::handleEvents ( int  usToWait = 0,
int  nEvents = 1,
const HandleEvent &  handleEvent = HandleEvent(),
const OnEvent &  beforeSleep = OnEvent(),
const OnEvent &  afterSleep = OnEvent() 
)

Wait up to the given number of microseconds and handle up to the given number of events.

The handleEvent function should return true if the loop should exit immediately, or false if there are other events to continue.

Returns the number of events handled or -1 if a handler forced the event handler to exit.

Definition at line 119 of file epoller.cc.

bool Datacratic::Epoller::poll ( ) const [virtual]

Returns true if there is work to be done. May be called from more than one thread. Should never block.

Reimplemented from Datacratic::AsyncEventSource.

Reimplemented in Datacratic::MessageLoop.

Definition at line 178 of file epoller.cc.

virtual bool Datacratic::Epoller::processOne ( ) [inline, virtual]

Process a single message and return true if there are more to be processed.

This may be called from more than one thread if singleThreaded() is false.

Implements Datacratic::AsyncEventSource.

Reimplemented in Datacratic::MessageLoop.

Definition at line 83 of file epoller.h.

Remove the given fd from the multiplexer set.

Definition at line 108 of file epoller.cc.

void Datacratic::Epoller::restartFdOneShot ( int  fd,
void *  data = 0 
)

Restart a woken up one-shot fd.

Definition at line 94 of file epoller.cc.

virtual int Datacratic::Epoller::selectFd ( ) const [inline, virtual]

Return the file descriptor on which one should select() for messages from this source. The source should organize itself such that if the fd indicates ready for a read, there is something to do.

Should return -1 if it requires polling.

Should never block.

Reimplemented from Datacratic::AsyncEventSource.

Definition at line 76 of file epoller.h.


Member Data Documentation

Default event handler function to use.

Definition at line 56 of file epoller.h.


The documentation for this struct was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator