![]() |
RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
Classes | |
| struct | SPLess |
Public Types | |
| typedef boost::function< void(TransportBase *) | OnTransportEvent ) |
Public Member Functions | |
| EndpointBase (const std::string &name) | |
| void | useThisThread () |
| void | shutdown () |
| virtual std::string | hostname () const =0 |
| virtual int | port () const =0 |
| void | sleepUntilIdle () const |
| int | threadsActive () const |
| virtual void | dumpState () const |
| virtual int | numConnections () const |
| virtual std::map< std::string, int > | numConnectionsByHost () const |
| const std::string & | name () const |
| void | makeRealTime (int priority=1) |
| virtual void | spinup (int num_threads, bool synchronous) |
Public Attributes | |
| boost::function< bool()> | onCheckFinished |
| OnTransportEvent | onTransportOpen |
| OnTransportEvent | onTransportClose |
Protected Types | |
|
typedef std::set < std::shared_ptr < TransportBase >, SPLess > | Connections |
| typedef ACE_Recursive_Thread_Mutex | Lock |
| typedef ACE_Guard< Lock > | Guard |
Protected Member Functions | |
| bool | checkFinished () const |
| virtual void | associateHandler (const std::shared_ptr< TransportBase > &transport) |
| virtual void | closePeer ()=0 |
| virtual void | notifyNewTransport (const std::shared_ptr< TransportBase > &transport) |
| virtual void | notifyCloseTransport (const std::shared_ptr< TransportBase > &transport) |
| virtual void | notifyRecycleTransport (const std::shared_ptr< TransportBase > &transport) |
| virtual void | restartPolling (TransportBase *transport) |
| virtual void | startPolling (TransportBase *transport) |
| virtual void | stopPolling (TransportBase *transport) |
| void | doAsync (const std::shared_ptr< TransportBase > &transport, const boost::function< void()> &callback, const char *nameOfCallback) |
Protected Attributes | |
| Connections | alive |
| Lock | lock |
| ACE_Semaphore | idle |
| bool | modifyIdle |
Friends | |
| class | TransportBase |
| class | ConnectionHandler |
| class | ConnectorT |
Definition at line 38 of file endpoint.h.
| typedef boost::function<void (TransportBase *) Datacratic::EndpointBase::OnTransportEvent) |
Thing to notify when a connection is closed. Will be called before the normal cleanup.
Definition at line 87 of file endpoint.h.
| virtual void Datacratic::EndpointBase::associateHandler | ( | const std::shared_ptr< TransportBase > & | transport | ) | [inline, protected, virtual] |
Factory method to associate a connection with a transport.
Reimplemented in Datacratic::PassiveEndpoint.
Definition at line 112 of file endpoint.h.
| bool Datacratic::EndpointBase::checkFinished | ( | ) | const [inline, protected] |
Callback to check in the loop if we're finished or not
Definition at line 104 of file endpoint.h.
| void Datacratic::EndpointBase::doAsync | ( | const std::shared_ptr< TransportBase > & | transport, |
| const boost::function< void()> & | callback, | ||
| const char * | nameOfCallback | ||
| ) | [protected] |
Perform the given callback asynchronously (in a worker thread) in the context of the given transport.
| void Datacratic::EndpointBase::dumpState | ( | ) | const [virtual] |
Dump the state of the endpoint for debugging.
Reimplemented in Datacratic::ActiveEndpoint.
Definition at line 299 of file endpoint.cc.
| virtual std::string Datacratic::EndpointBase::hostname | ( | ) | const [pure virtual] |
What host are we connected to?
Implemented in Datacratic::ActiveEndpoint, and Datacratic::PassiveEndpoint.
| void Datacratic::EndpointBase::makeRealTime | ( | int | priority = 1 | ) |
Set this endpoint up to handle events in realtime.
Definition at line 94 of file endpoint.cc.
| void Datacratic::EndpointBase::notifyCloseTransport | ( | const std::shared_ptr< TransportBase > & | transport | ) | [protected, virtual] |
Tell the endpoint that a connection has been closed.
Reimplemented in Datacratic::ActiveEndpoint, and Datacratic::RemoteOutput.
Definition at line 222 of file endpoint.cc.
| void Datacratic::EndpointBase::notifyNewTransport | ( | const std::shared_ptr< TransportBase > & | transport | ) | [protected, virtual] |
Tell the endpoint that a connection has been opened.
Reimplemented in Datacratic::ActiveEndpoint.
Definition at line 168 of file endpoint.cc.
| void Datacratic::EndpointBase::notifyRecycleTransport | ( | const std::shared_ptr< TransportBase > & | transport | ) | [protected, virtual] |
Tell the endpoint that a connection has been recycled. Default simply forwards to notifyCloseTransport.
Reimplemented in Datacratic::ActiveEndpoint.
Definition at line 265 of file endpoint.cc.
| int Datacratic::EndpointBase::numConnections | ( | ) | const [virtual] |
Return the number of connections for this client.
Definition at line 311 of file endpoint.cc.
| std::map< std::string, int > Datacratic::EndpointBase::numConnectionsByHost | ( | ) | const [virtual] |
Return the number of connections by host.
Definition at line 318 of file endpoint.cc.
| virtual int Datacratic::EndpointBase::port | ( | ) | const [pure virtual] |
What port are we listening on?
Implemented in Datacratic::ActiveEndpoint, and Datacratic::PassiveEndpoint.
| void Datacratic::EndpointBase::restartPolling | ( | TransportBase * | transport | ) | [protected, virtual] |
Re-enable polling after a transport has had it's one-shot event handler fire.
Definition at line 215 of file endpoint.cc.
| void Datacratic::EndpointBase::shutdown | ( | ) |
Shutdown everything in the bid manager. Opposite of init(). Will implicitly call notifyFinished() and wait for all threads to exit before returning.
Reimplemented in Datacratic::ActiveEndpoint, RTBKIT::HttpExchangeConnector, Datacratic::RemoteOutput, and RTBKIT::GenericExchangeConnector.
Definition at line 102 of file endpoint.cc.
| void Datacratic::EndpointBase::sleepUntilIdle | ( | ) | const |
Sleep until there are no active connections.
Definition at line 272 of file endpoint.cc.
| void Datacratic::EndpointBase::spinup | ( | int | num_threads, |
| bool | synchronous | ||
| ) | [virtual] |
Spin up the threads as part of the initialization. NOTE: make sure that this is only called once; normally it will be done as part of init(). Calling directly is only for advanced use where init() is not called.
Definition at line 60 of file endpoint.cc.
| void Datacratic::EndpointBase::startPolling | ( | TransportBase * | transport | ) | [protected, virtual] |
Add the transport to the set of events to be polled.
Definition at line 201 of file endpoint.cc.
| void Datacratic::EndpointBase::stopPolling | ( | TransportBase * | transport | ) | [protected, virtual] |
Remove the transport from the set of events to be polled.
Definition at line 208 of file endpoint.cc.
Add the current thread to those servicing requests. It will run until the endpoint is finished, either because notifyFinished() is called or because the checkFinished callback returns true and the kick() method is called.
Note that it is only necessary to call this method if it was initialized with threads == 0. Otherwise, there are threads already running.
Definition at line 161 of file endpoint.cc.
Connections Datacratic::EndpointBase::alive [protected] |
Set of alive connections. Used to know what connections are outstanding and to keep them alive while they are owned by the endpoint system.
Definition at line 135 of file endpoint.h.
ACE_Semaphore Datacratic::EndpointBase::idle [mutable, protected] |
released when there are no active connections
Definition at line 175 of file endpoint.h.
bool Datacratic::EndpointBase::modifyIdle [mutable, protected] |
Should the endpoint class manipulate the idle count?
Definition at line 178 of file endpoint.h.
| boost::function<bool ()> Datacratic::EndpointBase::onCheckFinished |
Function that will be called to know if we're finished.
Definition at line 68 of file endpoint.h.
1.7.6.1