MCPcopy Create free account
hub / github.com/BaseXdb/basex / release

Method release

basex-core/src/main/java/org/basex/core/locks/Locking.java:148–179  ·  view source on GitHub ↗

Removes locks for the specified job, all in reverse order.

()

Source from the content-addressed store, hash-verified

146 * Removes locks for the specified job, all in reverse order.
147 */
148 public void release() {
149 final Long id = Thread.currentThread().getId();
150 final Locks locks = locked.remove(id);
151 final LockList reads = locks.reads, writes = locks.writes;
152 final boolean lock = reads.locking() || writes.locking();
153
154 // release all local locks
155 for(final String string : reads) unpin(string).readLock().unlock();
156 for(final String string : writes) unpin(string).writeLock().unlock();
157
158 // allow next global reader to resume
159 synchronized(globalLock) {
160 if(reads.global()) {
161 globalReaders--;
162 globalLock.notifyAll();
163 }
164 }
165
166 // allow next local writer to resume
167 synchronized(globalLock) {
168 if(writes.local()) {
169 localWriters--;
170 globalLock.notifyAll();
171 }
172 }
173
174 // release exclusive lock (global write), or shared lock otherwise
175 if(lock) (writes.global() ? globalLocks.writeLock() : globalLocks.readLock()).unlock();
176
177 // allow next queued job to resume (non-locking jobs were never counted)
178 if(lock) queue.release();
179 }
180
181 /**
182 * Pins a lock string. Creates a new lock if necessary.

Callers 2

unregisterMethod · 0.45
lockMethod · 0.45

Calls 8

lockingMethod · 0.95
unpinMethod · 0.95
globalMethod · 0.95
localMethod · 0.95
readLockMethod · 0.80
writeLockMethod · 0.80
removeMethod · 0.65
getIdMethod · 0.45

Tested by

no test coverage detected