Sirikata
|
LocalForwarder maintains a map of objects that are directly connected to this space server. More...
#include <LocalForwarder.hpp>
Public Member Functions | |
LocalForwarder (SpaceContext *ctx) | |
Create a LocalForwarder. | |
void | addActiveConnection (ObjectConnection *conn) |
Notify the LocalForwarder that a new object connection is now available. | |
void | removeActiveConnection (const UUID &objid) |
Remove the connection for an object. | |
bool | tryForward (Sirikata::Protocol::Object::ObjectMessage *msg) |
Try to forward a message directly, shortcutting any forwarding code. | |
Private Types | |
typedef std::tr1::unordered_map< UUID, ObjectConnection *, UUID::Hasher > | ObjectConnectionMap |
Private Member Functions | |
virtual void | poll () |
Override this method to specify the work to be done when polling. | |
Private Attributes | |
SpaceContext * | mContext |
ObjectConnectionMap | mActiveConnections |
boost::mutex | mMutex |
Time | mLastStatsTime |
const String | mTimeSeriesForwardedName |
AtomicValue< uint32 > | mNumForwarded |
const String | mTimeSeriesDroppedName |
AtomicValue< uint32 > | mNumDropped |
LocalForwarder maintains a map of objects that are directly connected to this space server.
It operates in the same strand as the networking to allow very fast forwarding of messages between objects connected to the same space server.
typedef std::tr1::unordered_map<UUID, ObjectConnection*, UUID::Hasher> Sirikata::LocalForwarder::ObjectConnectionMap [private] |
Sirikata::LocalForwarder::LocalForwarder | ( | SpaceContext * | ctx | ) |
Create a LocalForwarder.
ctx | SpaceContext for this LocalForwarder to operate in |
References Sirikata::Context::add(), and mContext.
void Sirikata::LocalForwarder::addActiveConnection | ( | ObjectConnection * | conn | ) |
Notify the LocalForwarder that a new object connection is now available.
This transfers ownership of the ObjectConnection to the LocalForwarder.
conn | the new connection to add |
References Sirikata::ObjectConnection::id(), mActiveConnections, and mMutex.
Referenced by Sirikata::Server::finishAddObject(), Sirikata::Server::handleMigration(), and Sirikata::Server::processAlreadyMigrating().
void Sirikata::LocalForwarder::poll | ( | ) | [private, virtual] |
Override this method to specify the work to be done when polling.
Implements Sirikata::PollingService.
References mContext, mLastStatsTime, mNumDropped, mNumForwarded, mTimeSeriesDroppedName, mTimeSeriesForwardedName, Sirikata::AtomicValue< T >::read(), Sirikata::Context::recentSimTime(), Sirikata::Trace::TimeSeries::report(), and Sirikata::Context::timeSeries.
void Sirikata::LocalForwarder::removeActiveConnection | ( | const UUID & | objid | ) |
Remove the connection for an object.
objid | the UUID of the object to remove |
References mActiveConnections, and mMutex.
Referenced by Sirikata::Server::handleDisconnect(), Sirikata::Server::handleMigrationEvent(), and Sirikata::Server::processAlreadyMigrating().
bool Sirikata::LocalForwarder::tryForward | ( | Sirikata::Protocol::Object::ObjectMessage * | msg | ) |
Try to forward a message directly, shortcutting any forwarding code.
If forwarded, the LocalForwarder retains ownership of the message.
msg | the message to try to forward |
References Sirikata::Trace::DROPPED_AT_FORWARDED_LOCALLY, Sirikata::Trace::FORWARDED_LOCALLY, mActiveConnections, mContext, mMutex, mNumDropped, mNumForwarded, Sirikata::ObjectConnection::send(), Sirikata::Context::stopped(), TIMESTAMP_END, TIMESTAMP_START, and TRACE_DROP.
Referenced by Sirikata::Server::delegateODPPortSend(), Sirikata::Server::onObjectHostMessageReceived(), and Sirikata::Forwarder::serverMessageReceived().
Referenced by addActiveConnection(), removeActiveConnection(), and tryForward().
SpaceContext* Sirikata::LocalForwarder::mContext [private] |
Referenced by LocalForwarder(), poll(), and tryForward().
Time Sirikata::LocalForwarder::mLastStatsTime [private] |
Referenced by poll().
boost::mutex Sirikata::LocalForwarder::mMutex [private] |
Referenced by addActiveConnection(), removeActiveConnection(), and tryForward().
AtomicValue<uint32> Sirikata::LocalForwarder::mNumDropped [private] |
Referenced by poll(), and tryForward().
AtomicValue<uint32> Sirikata::LocalForwarder::mNumForwarded [private] |
Referenced by poll(), and tryForward().
const String Sirikata::LocalForwarder::mTimeSeriesDroppedName [private] |
Referenced by poll().
const String Sirikata::LocalForwarder::mTimeSeriesForwardedName [private] |
Referenced by poll().