Changeset 29484 in osm for applications/editors/josm/plugins/imagerycache/src/org/mapdb/CacheLRU.java
- Timestamp:
- 2013-04-07T17:07:27+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagerycache/src/org/mapdb/CacheLRU.java
r29363 r29484 1 1 package org.mapdb; 2 3 import java.util.concurrent.locks.ReentrantLock; 2 4 3 5 /** … … 10 12 protected LongMap<Object> cache; 11 13 12 protected final Locks.RecidLocks locks = new Locks.SegmentedRecidLocks(16);14 protected final ReentrantLock[] locks = Utils.newLocks(32); 13 15 14 16 … … 26 28 long recid = super.put(value, serializer); 27 29 try{ 28 locks.lock(recid);30 Utils.lock(locks,recid); 29 31 checkClosed(cache).put(recid, value); 30 32 }finally { 31 locks.unlock(recid);33 Utils.unlock(locks,recid); 32 34 } 33 35 return recid; … … 40 42 if(ret!=null) return (A) ret; 41 43 try{ 42 locks.lock(recid);44 Utils.lock(locks,recid); 43 45 ret = super.get(recid, serializer); 44 46 if(ret!=null) checkClosed(cache).put(recid, ret); 45 47 return (A) ret; 46 48 }finally { 47 locks.unlock(recid);49 Utils.unlock(locks,recid); 48 50 } 49 51 } … … 52 54 public <A> void update(long recid, A value, Serializer<A> serializer) { 53 55 try{ 54 locks.lock(recid);56 Utils.lock(locks,recid); 55 57 checkClosed(cache).put(recid, value); 56 58 super.update(recid, value, serializer); 57 59 }finally { 58 locks.unlock(recid);60 Utils.unlock(locks,recid); 59 61 } 60 62 } … … 63 65 public <A> void delete(long recid, Serializer<A> serializer){ 64 66 try{ 65 locks.lock(recid);67 Utils.lock(locks,recid); 66 68 checkClosed(cache).remove(recid); 67 69 super.delete(recid,serializer); 68 70 }finally { 69 locks.unlock(recid);71 Utils.unlock(locks,recid); 70 72 } 71 73 } … … 74 76 public <A> boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer) { 75 77 try{ 76 locks.lock(recid);78 Utils.lock(locks,recid); 77 79 Engine engine = getWrappedEngine(); 78 80 LongMap cache2 = checkClosed(cache); … … 89 91 } 90 92 }finally { 91 locks.unlock(recid);93 Utils.unlock(locks,recid); 92 94 } 93 95 }
Note:
See TracChangeset
for help on using the changeset viewer.