Changeset 29484 in osm for applications/editors/josm/plugins/imagerycache/src/org/mapdb/CacheWeakSoftRef.java
- Timestamp:
- 2013-04-07T17:07:27+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagerycache/src/org/mapdb/CacheWeakSoftRef.java
r29363 r29484 20 20 import java.lang.ref.SoftReference; 21 21 import java.lang.ref.WeakReference; 22 import java.util.concurrent.locks.ReentrantLock; 22 23 23 24 /** … … 30 31 31 32 32 protected final Locks.RecidLockslocks =new Locks.LongHashMapRecidLocks();33 protected final ReentrantLock[] locks = Utils.newLocks(32); 33 34 34 35 protected interface CacheItem{ … … 130 131 131 132 try{ 132 locks.lock(recid);133 Utils.lock(locks,recid); 133 134 Object value = getWrappedEngine().get(recid, serializer); 134 135 if(value!=null) putItemIntoCache(recid, value); … … 136 137 return (A) value; 137 138 }finally{ 138 locks.unlock(recid);139 Utils.unlock(locks,recid); 139 140 } 140 141 … … 144 145 public <A> void update(long recid, A value, Serializer<A> serializer) { 145 146 try{ 146 locks.lock(recid);147 Utils.lock(locks,recid); 147 148 putItemIntoCache(recid, value); 148 149 getWrappedEngine().update(recid, value, serializer); 149 150 }finally { 150 locks.unlock(recid);151 Utils.unlock(locks,recid); 151 152 } 152 153 } … … 163 164 public <A> void delete(long recid, Serializer<A> serializer){ 164 165 try{ 165 locks.lock(recid);166 Utils.lock(locks,recid); 166 167 checkClosed(items).remove(recid); 167 168 getWrappedEngine().delete(recid,serializer); 168 169 }finally { 169 locks.unlock(recid);170 Utils.unlock(locks,recid); 170 171 } 171 172 … … 175 176 public <A> boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer) { 176 177 try{ 177 locks.lock(recid);178 Utils.lock(locks,recid); 178 179 CacheItem item = checkClosed(items).get(recid); 179 180 Object oldValue = item==null? null: item.get() ; … … 190 191 } 191 192 }finally { 192 locks.unlock(recid);193 Utils.unlock(locks,recid); 193 194 } 194 195 }
Note:
See TracChangeset
for help on using the changeset viewer.