Author: toad
Date: 2006-11-27 22:30:47 +0000 (Mon, 27 Nov 2006)
New Revision: 11074

Modified:
   trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
   
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
Log:
Better clear()ing and kill()ing.

Modified: trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
===================================================================
--- trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java    
2006-11-27 22:29:56 UTC (rev 11073)
+++ trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java    
2006-11-27 22:30:47 UTC (rev 11074)
@@ -11,7 +11,7 @@
  */
 public class UpdatableSortedLinkedList {

-       private boolean killed = false;
+       protected boolean killed = false;
        private static boolean logMINOR;

     public UpdatableSortedLinkedList() {

Modified: 
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
===================================================================
--- 
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
    2006-11-27 22:29:56 UTC (rev 11073)
+++ 
trunk/freenet/src/freenet/support/UpdatableSortedLinkedListWithForeignIndex.java
    2006-11-27 22:30:47 UTC (rev 11074)
@@ -22,6 +22,7 @@
         if(!(item instanceof IndexableUpdatableSortedLinkedListItem)) {
             throw new IllegalArgumentException();
         }
+       if(killed) throw new UpdatableSortedLinkedListKilledException();
         IndexableUpdatableSortedLinkedListItem i = 
(IndexableUpdatableSortedLinkedListItem)item;
         if(map.get(i.indexValue()) != null) {
             // Ignore duplicate
@@ -34,6 +35,7 @@
     }

     public synchronized UpdatableSortedLinkedListItem 
remove(UpdatableSortedLinkedListItem item) throws 
UpdatableSortedLinkedListKilledException {
+       if(killed) throw new UpdatableSortedLinkedListKilledException();
         
map.remove(((IndexableUpdatableSortedLinkedListItem)item).indexValue());
         return super.remove(item);
     }
@@ -47,10 +49,16 @@
      * @throws UpdatableSortedLinkedListKilledException 
      */
     public synchronized IndexableUpdatableSortedLinkedListItem 
removeByKey(Object key) throws UpdatableSortedLinkedListKilledException {
+       if(killed) throw new UpdatableSortedLinkedListKilledException();
         IndexableUpdatableSortedLinkedListItem item = 
             (IndexableUpdatableSortedLinkedListItem) map.get(key);
         if(item != null) remove(item);
         checkList();
         return item;
     }
+    
+    public synchronized void clear() {
+       map.clear();
+       super.clear();
+    }
 }


Reply via email to