Sirikata
|
OSegLookupQueue manages outstanding OSeg lookups. More...
#include <OSegLookupQueue.hpp>
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::IOStrand * | mNetworkStrand |
ObjectSegmentation * | mOSeg |
LookupMap | mLookups |
int32 | mTotalSize |
uint32 | mMaxLookups |
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.
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] |
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.
net_strand | the strand used for networking, i.e. the one which should handle lookup results |
oseg | the ObjectSegmentation which resolves queries |
References Sirikata::GetOptionValue< uint32 >(), mMaxLookups, mOSeg, OSEG_LOOKUP_QUEUE_SIZE, and Sirikata::ObjectSegmentation::setLookupListener().
virtual Sirikata::OSegLookupQueue::~OSegLookupQueue | ( | ) | [inline, virtual] |
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().
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.
msg | the ObjectMessage to perform the lookup for |
cb | the callback to invoke when the lookup is complete |
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] |
Implements Sirikata::OSegLookupListener.
References handleLookupCompleted(), mNetworkStrand, and Sirikata::Network::IOStrand::post().
LookupMap Sirikata::OSegLookupQueue::mLookups [private] |
Referenced by handleLookupCompleted(), and lookup().
uint32 Sirikata::OSegLookupQueue::mMaxLookups [private] |
Referenced by lookup(), and OSegLookupQueue().
Referenced by osegLookupCompleted().
Referenced by cacheLookup(), lookup(), and OSegLookupQueue().
int32 Sirikata::OSegLookupQueue::mTotalSize [private] |
Referenced by handleLookupCompleted(), lookup(), and Sirikata::OSegLookupQueue::OSegLookupList::push_back().