diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-09-25 18:57:39 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-09-25 18:57:39 +0000 |
commit | a343e9abb3e49dfdc69b0f961ad992f67a90b8a5 (patch) | |
tree | 987bfb62bc709d016d52844fd9cd9d50fa7cbd2d | |
parent | bug fix - evict() only evicted at most one servant (diff) | |
download | ice-a343e9abb3e49dfdc69b0f961ad992f67a90b8a5.tar.bz2 ice-a343e9abb3e49dfdc69b0f961ad992f67a90b8a5.tar.xz ice-a343e9abb3e49dfdc69b0f961ad992f67a90b8a5.zip |
copy the identities to allow concurrent database access
-rw-r--r-- | java/src/Freeze/EvictorIteratorI.java | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/java/src/Freeze/EvictorIteratorI.java b/java/src/Freeze/EvictorIteratorI.java index e0139ca5596..213294aa3c5 100644 --- a/java/src/Freeze/EvictorIteratorI.java +++ b/java/src/Freeze/EvictorIteratorI.java @@ -14,33 +14,46 @@ class EvictorIteratorI extends Ice.LocalObjectImpl implements EvictorIterator { EvictorIteratorI(java.util.Iterator iterator) { - _iterator = iterator; + // + // Copy the identities from the map iterator, to allow + // this iterator to continue to function even if the + // database is accessed and the map iterator is invalidated. + // + java.util.ArrayList list = new java.util.ArrayList(); + while(iterator.hasNext()) + { + list.add(iterator.next()); + } + _identities= new Ice.Identity[list.size()]; + list.toArray(_identities); + _pos = 0; } public boolean hasNext() { - return _iterator.hasNext(); + return _pos < _identities.length; } public Ice.Identity next() { - try - { - return (Ice.Identity)((Map.Entry)_iterator.next()).getKey(); - } - catch(java.util.NoSuchElementException e) - { - throw new Freeze.NoSuchElementException(); - } + if(_pos < _identities.length) + { + return _identities[_pos++]; + } + else + { + throw new Freeze.NoSuchElementException(); + } } public void destroy() { - ((Map.EntryIterator)_iterator).close(); + _pos = _identities.length; } - private java.util.Iterator _iterator; + private Ice.Identity[] _identities; + private int _pos; } |