Update of /var/cvs/src/org/mmbase/util
In directory james.mmbase.org:/tmp/cvs-serv10325
Modified Files:
LRUHashtable.java
Log Message:
MMB-1667, changed locking object, and made it explicit
See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/util
See also: http://www.mmbase.org/jira/browse/MMB-1667
Index: LRUHashtable.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/util/LRUHashtable.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- LRUHashtable.java 1 Aug 2007 06:44:43 -0000 1.30
+++ LRUHashtable.java 24 Jun 2008 10:01:05 -0000 1.31
@@ -21,7 +21,7 @@
* @move consider moving to org.mmbase.cache
* @author Rico Jansen
* @author Michiel Meeuwissen
- * @version $Id: LRUHashtable.java,v 1.30 2007/08/01 06:44:43 michiel Exp $
+ * @version $Id: LRUHashtable.java,v 1.31 2008/06/24 10:01:05 michiel Exp $
* @see org.mmbase.cache.Cache
* @deprecated use org.mmbase.cache.implementation.LRUCache
*/
@@ -87,13 +87,18 @@
this(100, 101, 0.75f);
}
+ public Object getLock() {
+ return backing;
+ }
+
/**
* Store an element in the table.
* @param key the key of the element
* @param value the value of the element
* @return the original value of the element if it existed,
<code>null</code> if it could not be found
*/
- public synchronized V put(K key, V value) {
+ public V put(K key, V value) {
+ synchronized(backing) {
LRUEntry work = backing.get(key);
V rtn;
if (work != null) {
@@ -116,6 +121,8 @@
}
}
return rtn;
+
+ }
}
public void putAll(Map<? extends K, ? extends V> t) {
@@ -151,7 +158,8 @@
* @param key the key of the element
* @return the value of the element, or <code>null</code> if it could not
be found
*/
- public synchronized V get(Object key) {
+ public V get(Object key) {
+ synchronized(backing) {
LRUEntry work = backing.get(key);
if (work != null) {
work.requestCount++;
@@ -163,13 +171,15 @@
return null;
}
}
+ }
/**
* Remove an element from the table.
* @param key the key of the element
* @return the original value of the element if it existed,
<code>null</code> if it could not be found
*/
- public synchronized V remove(Object key) {
+ public V remove(Object key) {
+ synchronized(backing) {
LRUEntry work = backing.remove(key);
if (work != null) {
V rtn = work.value;
@@ -179,6 +189,7 @@
return null;
}
}
+ }
/**
@@ -288,22 +299,24 @@
/**
* Clears the table.
*/
- public synchronized void clear() {
+ public void clear() {
+ synchronized(backing) {
while (root.next != dangling) removeEntry(root.next);
backing.clear();
}
+ }
/**
* NOT IMPLEMENTED
*/
- public synchronized Object clone() {
+ public Object clone() {
throw new UnsupportedOperationException();
}
/**
* Returns an <code>Enumeration</code> on the table's element values.
*/
- public synchronized Enumeration<V> elements() {
+ public Enumeration<V> elements() {
return new LRUHashtableEnumeration();
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs