Sirikata
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
Sirikata::OSegLookupQueue Class Reference

OSegLookupQueue manages outstanding OSeg lookups. More...

#include <OSegLookupQueue.hpp>

Inheritance diagram for Sirikata::OSegLookupQueue:
Collaboration diagram for Sirikata::OSegLookupQueue:

List of all members.

Classes

struct  OSegLookup
class  OSegLookupList
 A normal vector of OSegLookups except it also maintains the total size of all its elements. More...

Public Types

enum  ResolvedFrom { ResolvedFromCache, ResolvedFromServer }
typedef std::tr1::function
< void(Sirikata::Protocol::Object::ObjectMessage
*, const OSegEntry
&, ResolvedFrom
LookupCallback )
 Callback type for lookups, taking the message the lookup was performed on, the ServerID the OSeg returned, and an enum indicating how the lookup was resolved.

Public Member Functions

 OSegLookupQueue (Network::IOStrand *net_strand, ObjectSegmentation *oseg)
 Create an OSegLookupQueue which uses the specified ObjectSegmentation to resolve queries and the specified predicate to determine if new lookups are accepted.
virtual ~OSegLookupQueue ()
OSegEntry cacheLookup (const UUID &destid) const
 Perform an OSeg cache lookup, returning the ServerID or NullServerID if the cache doesn't contain an entry for the object.
bool lookup (Sirikata::Protocol::Object::ObjectMessage *msg, const LookupCallback &cb)
 Perform an OSeg lookup, calling the specified callback when the result is available.

Private Types

typedef
std::tr1::unordered_map< UUID,
OSegLookupList, UUID::Hasher
LookupMap

Private Member Functions

virtual void osegLookupCompleted (const UUID &id, const OSegEntry &dest)
void handleLookupCompleted (const UUID &id, const OSegEntry &dest)

Private Attributes

Network::IOStrandmNetworkStrand
ObjectSegmentationmOSeg
LookupMap mLookups
int32 mTotalSize
uint32 mMaxLookups

Detailed Description

OSegLookupQueue manages outstanding OSeg lookups.

Lookups are submitted and either accepted and we commit to finishing them or rejected immediately. The user can specify a policy for how these rejections occur, e.g. based on a total number of outstanding lookups, a total number of bytes in messages for outstanding lookups, etc.


Member Typedef Documentation

typedef std::tr1::function<void(Sirikata::Protocol::Object::ObjectMessage*, const OSegEntry&, ResolvedFrom) Sirikata::OSegLookupQueue::LookupCallback)

Callback type for lookups, taking the message the lookup was performed on, the ServerID the OSeg returned, and an enum indicating how the lookup was resolved.

If you need additional information it must be curried via bind().

typedef std::tr1::unordered_map<UUID, OSegLookupList, UUID::Hasher> Sirikata::OSegLookupQueue::LookupMap [private]

Member Enumeration Documentation

Enumerator:
ResolvedFromCache 
ResolvedFromServer 

Constructor & Destructor Documentation

Sirikata::OSegLookupQueue::OSegLookupQueue ( Network::IOStrand net_strand,
ObjectSegmentation oseg 
)

Create an OSegLookupQueue which uses the specified ObjectSegmentation to resolve queries and the specified predicate to determine if new lookups are accepted.

Parameters:
net_strandthe strand used for networking, i.e. the one which should handle lookup results
osegthe ObjectSegmentation which resolves queries

References Sirikata::GetOptionValue< uint32 >(), mMaxLookups, mOSeg, OSEG_LOOKUP_QUEUE_SIZE, and Sirikata::ObjectSegmentation::setLookupListener().

virtual Sirikata::OSegLookupQueue::~OSegLookupQueue ( ) [inline, virtual]

Member Function Documentation

OSegEntry Sirikata::OSegLookupQueue::cacheLookup ( const UUID destid) const

Perform an OSeg cache lookup, returning the ServerID or NullServerID if the cache doesn't contain an entry for the object.

References Sirikata::ObjectSegmentation::cacheLookup(), and mOSeg.

Referenced by Sirikata::Forwarder::tryCacheForward().

void Sirikata::OSegLookupQueue::handleLookupCompleted ( const UUID id,
const OSegEntry dest 
) [private]
bool Sirikata::OSegLookupQueue::lookup ( Sirikata::Protocol::Object::ObjectMessage *  msg,
const LookupCallback cb 
)

Perform an OSeg lookup, calling the specified callback when the result is available.

If the result is available immediately, the callback may be triggered during this call. Otherwise, it will be triggered when a service() call produces a result. Note that if the request is accepted, the message is owned by the OSegLookupQueue until the callback is invoked, at which time control is passed back to the caller.

Parameters:
msgthe ObjectMessage to perform the lookup for
cbthe callback to invoke when the lookup is complete
Returns:
true if the lookup was accepted, false if it was rejected (due to the push predicate).

References Sirikata::ObjectSegmentation::cacheLookup(), Sirikata::OSegLookupQueue::OSegLookup::cb, Sirikata::ObjectSegmentation::getPushback(), Sirikata::ObjectSegmentation::lookup(), MAX_OSEG_PUSHBACK_PARAMETER, mLookups, mMaxLookups, mOSeg, Sirikata::OSegLookupQueue::OSegLookup::msg, mTotalSize, Sirikata::OSegEntry::notNull(), ResolvedFromCache, and Sirikata::OSegLookupQueue::OSegLookup::size.

Referenced by Sirikata::Forwarder::forward().

void Sirikata::OSegLookupQueue::osegLookupCompleted ( const UUID id,
const OSegEntry dest 
) [private, virtual]

Member Data Documentation

Referenced by handleLookupCompleted(), and lookup().

Referenced by lookup(), and OSegLookupQueue().

Referenced by osegLookupCompleted().


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