![]() |
RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
#include <transport.h>
Classes | |
struct | Activities |
struct | Activity |
struct | AsyncEntry |
struct | AsyncNode |
struct | InHandlerGuard |
struct | Timeout |
Public Member Functions | |
TransportBase (EndpointBase *endpoint) | |
virtual int | handleInput () |
virtual int | handleOutput () |
virtual int | handlePeerShutdown () |
virtual int | handleTimeout () |
virtual int | handleError (const std::string &error) |
virtual int | handleAsync (const boost::function< void()> &callback, const char *name, Date dateSet) |
virtual ssize_t | send (const char *buf, size_t len, int flags)=0 |
virtual ssize_t | recv (char *buf, size_t buf_size, int flags)=0 |
virtual int | closePeer ()=0 |
virtual int | getHandle () const =0 |
EndpointBase * | get_endpoint () |
void | recycleWhenHandlerFinished () |
void | closeWhenHandlerFinished () |
void | closeAsync () |
void | associate (std::shared_ptr< ConnectionHandler > newSlave) |
void | associateWhenHandlerFinished (std::shared_ptr< ConnectionHandler > newSlave, const std::string &whereFrom) |
void | startReading () |
void | stopReading () |
void | startWriting () |
void | stopWriting () |
void | scheduleTimerAbsolute (Date timeout, size_t cookie=0, void(*freecookie)(size_t)=0) |
void | scheduleTimerRelative (double secondsFromNow, size_t cookie=0, void(*freecookie)(size_t)=0) |
void | cancelTimer () |
void | doAsync (const boost::function< void()> &callback, const std::string &name) |
virtual std::string | getPeerName () const =0 |
bool | hasSlave () const |
void | doError (const std::string &error) |
virtual std::string | status () const |
bool | debugOn () const |
void | addActivity (const std::string &act) |
void | addActivityS (const char *act) |
void | addActivity (const char *fmt,...) |
void | dumpActivities () const |
bool | hasAsync () const |
void | pushAsync (const boost::function< void()> &fn, const std::string &name) |
std::vector< AsyncEntry > | popAsync () |
bool | isZombie () const |
bool | locked () const |
bool | lockedByThisThread () const |
void | assertLockedByThisThread () const |
void | assertNotLockedByAnotherThread () const |
void | checkMagic () const |
ConnectionHandler & | slave () |
bool | hasTimeout () const |
Date | nextTimeout () const |
void | hasConnection () |
Public Attributes | |
bool | debug |
Activities | activities |
AsyncNode * | asyncHead_ |
Static Public Attributes | |
static long | created = 0 |
static long | destroyed = 0 |
Protected Attributes | |
long long | lockThread |
For debug for the moment. | |
const char * | lockActivity |
Friends | |
class | EndpointBase |
class | ActiveEndpoint |
class | PassiveEndpoint |
Deals with the underlying socket infrastructure.
Definition at line 42 of file transport.h.
void Datacratic::TransportBase::assertLockedByThisThread | ( | ) | const [inline] |
Check that we're locked by this thread; throw otherwise
Definition at line 406 of file transport.h.
void Datacratic::TransportBase::assertNotLockedByAnotherThread | ( | ) | const [inline] |
Check that we're not locked by another thread; throw otherwise
Definition at line 417 of file transport.h.
void Datacratic::TransportBase::associate | ( | std::shared_ptr< ConnectionHandler > | newSlave | ) |
Associate the given connection handler with this transport. Any activity on the transport will be handled by the slave. The transport takes ownership of the connection handler and will arrange for it to be freed once it is no longer needed.
Not to be called within a handler.
Definition at line 307 of file transport.cc.
void Datacratic::TransportBase::associateWhenHandlerFinished | ( | std::shared_ptr< ConnectionHandler > | newSlave, |
const std::string & | whereFrom | ||
) |
Associates a new handler once the current handler is finished.
Definition at line 400 of file transport.cc.
Cancel the timer for this connection if it exists.
Definition at line 835 of file transport.cc.
void Datacratic::TransportBase::checkMagic | ( | ) | const |
Check that the magic number is correct and that therefore the transport is still alive.
Definition at line 118 of file transport.cc.
Close the transport asynchronously whenever the current handler (if any) has finished running. Can be called from outsied a handler.
Definition at line 392 of file transport.cc.
Close the current transport once the current handler is finished. Can only be called from within a handler.
Definition at line 377 of file transport.cc.
void Datacratic::TransportBase::doAsync | ( | const boost::function< void()> & | callback, |
const std::string & | name | ||
) |
Run the given function from a worker thread in the context of this handler.
Definition at line 847 of file transport.cc.
virtual std::string Datacratic::TransportBase::getPeerName | ( | ) | const [pure virtual] |
Return the hostname of the connected entity.
Implemented in Datacratic::SocketTransport.
Called by something that creates transports to say that it now has a connection associated with it. This causes a bunch of internal setup to happen.
Definition at line 536 of file transport.cc.
std::vector< TransportBase::AsyncEntry > Datacratic::TransportBase::popAsync | ( | ) |
Return the current async list in order and reset it to empty. Thread safe and lock free.
Definition at line 876 of file transport.cc.
void Datacratic::TransportBase::pushAsync | ( | const boost::function< void()> & | fn, |
const std::string & | name | ||
) |
Push an asynchronous entry onto the list. Thread safe and lock free.
Definition at line 855 of file transport.cc.
Recycles the current transport with the endpoint, disassociating the connection handler in the process.
All this does is set a flag; the actual work will be done after the current handler has finished.
Definition at line 365 of file transport.cc.
void Datacratic::TransportBase::scheduleTimerAbsolute | ( | Date | timeout, |
size_t | cookie = 0 , |
||
void(*)(size_t) | freecookie = 0 |
||
) |
Schedule a timeout at the given absolute time. Only one timer is available per connection.
Definition at line 799 of file transport.cc.
void Datacratic::TransportBase::scheduleTimerRelative | ( | double | secondsFromNow, |
size_t | cookie = 0 , |
||
void(*)(size_t) | freecookie = 0 |
||
) |
Schedule a timeout at the given number of seconds from now. Again, only one timer is available per connection.
Definition at line 813 of file transport.cc.
Head of list of asynchronous entry nodes.
Definition at line 380 of file transport.h.
long Datacratic::TransportBase::created = 0 [static] |
To enable memory leak detection.
Definition at line 146 of file transport.h.