Changeset 29484 in osm for applications/editors/josm/plugins/imagerycache/src/org/mapdb/CacheHashTable.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/CacheHashTable.java
r29363 r29484 17 17 package org.mapdb; 18 18 19 import java.util.concurrent.locks.ReentrantLock; 20 19 21 /** 20 22 * Fixed size cache which uses hash table. … … 29 31 30 32 31 protected final Locks.RecidLocks locks = new Locks.SegmentedRecidLocks(16);33 protected final ReentrantLock[] locks = Utils.newLocks(32); 32 34 33 35 protected HashItem[] items; … … 63 65 final int pos = position(recid); 64 66 try{ 65 locks.lock(pos);67 Utils.lock(locks,pos); 66 68 checkClosed(items)[position(recid)] = new HashItem(recid, value); 67 69 }finally{ 68 locks.unlock(pos);70 Utils.unlock(locks,pos); 69 71 } 70 72 return recid; … … 81 83 82 84 try{ 83 locks.lock(pos);85 Utils.lock(locks,pos); 84 86 //not in cache, fetch and add 85 87 final A value = getWrappedEngine().get(recid, serializer); … … 88 90 return value; 89 91 }finally{ 90 locks.unlock(pos);92 Utils.unlock(locks,pos); 91 93 } 92 94 } … … 100 102 final int pos = position(recid); 101 103 try{ 102 locks.lock(pos);104 Utils.lock(locks,pos); 103 105 checkClosed(items)[pos] = new HashItem(recid, value); 104 106 getWrappedEngine().update(recid, value, serializer); 105 107 }finally { 106 locks.unlock(pos);108 Utils.unlock(locks,pos); 107 109 } 108 110 } … … 113 115 try{ 114 116 HashItem[] items2 = checkClosed(items); 115 locks.lock(pos);117 Utils.lock(locks,pos); 116 118 HashItem item = items2[pos]; 117 119 if(item!=null && item.key == recid){ … … 131 133 } 132 134 }finally { 133 locks.unlock(pos);135 Utils.unlock(locks,pos); 134 136 } 135 137 } … … 139 141 final int pos = position(recid); 140 142 try{ 141 locks.lock(recid);143 Utils.lock(locks,pos); 142 144 getWrappedEngine().delete(recid,serializer); 143 145 HashItem[] items2 = checkClosed(items); … … 146 148 items[pos] = null; 147 149 }finally { 148 locks.unlock(recid);150 Utils.unlock(locks,pos); 149 151 } 150 152
Note:
See TracChangeset
for help on using the changeset viewer.