![]() |
RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
#include <epoller.h>
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 |
Basic wrapper around the epoll interface to turn it into an async event source.
| 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.
| void Datacratic::Epoller::removeFd | ( | int | fd | ) |
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.
| HandleEvent Datacratic::Epoller::handleEvent |
1.7.6.1