Changeset 29484 in osm for applications/editors/josm/plugins/imagerycache/src/org/mapdb/SnapshotEngine.java
- Timestamp:
- 2013-04-07T17:07:27+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagerycache/src/org/mapdb/SnapshotEngine.java
r29363 r29484 3 3 import java.util.Map; 4 4 import java.util.concurrent.ConcurrentHashMap; 5 import java.util.concurrent.locks.ReentrantLock; 5 6 import java.util.concurrent.locks.ReentrantReadWriteLock; 6 7 … … 15 16 public class SnapshotEngine extends EngineWrapper{ 16 17 17 protected final Locks.RecidLockslocks =new Locks.LongHashMapRecidLocks();18 protected final ReentrantLock[] locks = Utils.newLocks(32); 18 19 19 20 protected final static Object NOT_EXIST = new Object(); … … 38 39 public <A> long put(A value, Serializer<A> serializer) { 39 40 long recid = super.put(value, serializer); 40 locks.lock(recid);41 Utils.lock(locks,recid); 41 42 try{ 42 43 for(Snapshot s:snapshots.keySet()){ … … 45 46 return recid; 46 47 }finally{ 47 locks.unlock(recid);48 Utils.unlock(locks,recid); 48 49 } 49 50 } … … 51 52 @Override 52 53 public <A> boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer) { 53 locks.lock(recid);54 Utils.lock(locks,recid); 54 55 try{ 55 56 boolean ret = super.compareAndSwap(recid, expectedOldValue, newValue, serializer); … … 61 62 return ret; 62 63 }finally{ 63 locks.unlock(recid);64 Utils.unlock(locks,recid); 64 65 } 65 66 } … … 67 68 @Override 68 69 public <A> void update(long recid, A value, Serializer<A> serializer) { 69 locks.lock(recid);70 Utils.lock(locks,recid); 70 71 try{ 71 72 Object val = NOT_INIT_YET; … … 80 81 super.update(recid, value, serializer); 81 82 }finally{ 82 locks.unlock(recid);83 Utils.unlock(locks,recid); 83 84 } 84 85 } … … 86 87 @Override 87 88 public <A> void delete(long recid, Serializer<A> serializer) { 88 locks.lock(recid);89 Utils.lock(locks,recid); 89 90 try{ 90 91 Object val = NOT_INIT_YET; … … 99 100 super.delete(recid,serializer); 100 101 }finally{ 101 locks.unlock(recid);102 Utils.unlock(locks,recid); 102 103 } 103 104 } … … 131 132 @Override 132 133 public <A> A get(long recid, Serializer<A> serializer) { 133 locks.lock(recid);134 Utils.lock(locks,recid); 134 135 try{ 135 136 Object ret = oldValues.get(recid); … … 140 141 return SnapshotEngine.this.getWrappedEngine().get(recid, serializer); 141 142 }finally{ 142 locks.unlock(recid);143 Utils.unlock(locks,recid); 143 144 } 144 145 }
Note:
See TracChangeset
for help on using the changeset viewer.
