Sirikata
Public Member Functions | Private Types | Private Member Functions | Private Attributes
Sirikata::LocalForwarder Class Reference

LocalForwarder maintains a map of objects that are directly connected to this space server. More...

#include <LocalForwarder.hpp>

Inheritance diagram for Sirikata::LocalForwarder:
Collaboration diagram for Sirikata::LocalForwarder:

List of all members.

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

SpaceContextmContext
ObjectConnectionMap mActiveConnections
boost::mutex mMutex
Time mLastStatsTime
const String mTimeSeriesForwardedName
AtomicValue< uint32 > mNumForwarded
const String mTimeSeriesDroppedName
AtomicValue< uint32 > mNumDropped

Detailed Description

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.


Member Typedef Documentation


Constructor & Destructor Documentation

Sirikata::LocalForwarder::LocalForwarder ( SpaceContext ctx)

Create a LocalForwarder.

Parameters:
ctxSpaceContext for this LocalForwarder to operate in

References Sirikata::Context::add(), and mContext.


Member Function Documentation

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.

Parameters:
connthe 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]
void Sirikata::LocalForwarder::removeActiveConnection ( const UUID objid)

Remove the connection for an object.

Parameters:
objidthe 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.

Parameters:
msgthe message to try to forward
Returns:
true if the message was forwarded, false otherwise

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().


Member Data Documentation

Referenced by LocalForwarder(), poll(), and tryForward().

Referenced by poll().

boost::mutex Sirikata::LocalForwarder::mMutex [private]

Referenced by poll(), and tryForward().

Referenced by poll(), and tryForward().

Referenced by poll().

Referenced by poll().


The documentation for this class was generated from the following files: