From 0b033b200be5091b31fa28445a59c47c6ee5927c Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Tue, 9 May 2006 10:07:56 +0000 Subject: Fix --- cpp/src/IceGrid/ObjectCache.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'cpp/src/IceGrid/ObjectCache.cpp') diff --git a/cpp/src/IceGrid/ObjectCache.cpp b/cpp/src/IceGrid/ObjectCache.cpp index c8694cac6fd..27ee6086d7b 100644 --- a/cpp/src/IceGrid/ObjectCache.cpp +++ b/cpp/src/IceGrid/ObjectCache.cpp @@ -55,6 +55,11 @@ ObjectCache::TypeEntry::add(const ObjectEntryPtr& obj) // _objects.insert(lower_bound(_objects.begin(), _objects.end(), obj, ObjectEntryCI()), obj); _allocatablesCount += obj->isAllocatable() ? 1 : 0; + + if(!_requests.empty()) + { + canTryAllocate(obj, false); + } } bool @@ -67,6 +72,14 @@ ObjectCache::TypeEntry::remove(const ObjectEntryPtr& obj) vector::iterator q = lower_bound(_objects.begin(), _objects.end(), obj, ObjectEntryCI()); assert(q->get() == obj.get()); _objects.erase(q); + + if(!_requests.empty() && !_allocatablesCount) + { + for(vector::const_iterator p = _requests.begin(); p != _requests.end(); ++p) + { + (*p)->cancel(AllocationException("no allocatable objects with type `" + obj->getType() + "' registered")); + } + } return _objects.empty(); } @@ -76,6 +89,7 @@ ObjectCache::TypeEntry::addAllocationRequest(const ObjectAllocationRequestPtr& r // // No mutex protection here, this is called with the cache locked. // + assert(_allocatablesCount); if(request->pending()) { _requests.push_back(request); @@ -83,7 +97,7 @@ ObjectCache::TypeEntry::addAllocationRequest(const ObjectAllocationRequestPtr& r } bool -ObjectCache::TypeEntry::canTryAllocate(const ObjectEntryPtr& entry) +ObjectCache::TypeEntry::canTryAllocate(const ObjectEntryPtr& entry, bool fromRelease) { // // No mutex protection here, this is called with the cache locked. @@ -98,7 +112,7 @@ ObjectCache::TypeEntry::canTryAllocate(const ObjectEntryPtr& entry) { p = _requests.erase(p); } - else if(entry->tryAllocate(request, true)) + else if(entry->tryAllocate(request, fromRelease)) { p = _requests.erase(p); return true; // The request successfully allocated the entry! @@ -233,7 +247,7 @@ ObjectCache::canTryAllocate(const ObjectEntryPtr& entry) { return false; } - return p->second.canTryAllocate(entry); + return p->second.canTryAllocate(entry, true); } Ice::ObjectProxySeq -- cgit v1.2.3