use of java.util.concurrent.locks.ReentrantLock in project geode by apache.
the class ForceableLinkedBlockingQueue method signalNotEmpty.
/**
* Signals a waiting take. Called only from put/offer (which do not otherwise ordinarily lock
* takeLock.)
*/
private void signalNotEmpty() {
final ReentrantLock takeLock = this.takeLock;
takeLock.lock();
try {
notEmpty.signal();
} finally {
takeLock.unlock();
}
}
use of java.util.concurrent.locks.ReentrantLock in project geode by apache.
the class ForceableLinkedBlockingQueue method signalNotFull.
/**
* Signals a waiting put. Called only from take/poll.
*/
private void signalNotFull() {
final ReentrantLock putLock = this.putLock;
putLock.lock();
try {
notFull.signal();
} finally {
putLock.unlock();
}
}
use of java.util.concurrent.locks.ReentrantLock in project geode by apache.
the class ForceableLinkedBlockingQueue method poll.
public E poll() {
final AtomicInteger count = this.count;
if (count.get() == 0)
return null;
E x = null;
int c = -1;
final ReentrantLock takeLock = this.takeLock;
takeLock.lock();
try {
if (count.get() > 0) {
x = dequeue();
c = count.getAndDecrement();
if (c > 1)
notEmpty.signal();
}
} finally {
takeLock.unlock();
}
if (c == capacity)
signalNotFull();
return x;
}
use of java.util.concurrent.locks.ReentrantLock in project geode by apache.
the class ForceableLinkedBlockingQueue method take.
public E take() throws InterruptedException {
E x;
int c = -1;
final AtomicInteger count = this.count;
final ReentrantLock takeLock = this.takeLock;
takeLock.lockInterruptibly();
try {
while (count.get() == 0) {
notEmpty.await();
}
x = dequeue();
c = count.getAndDecrement();
if (c > 1)
notEmpty.signal();
} finally {
takeLock.unlock();
}
if (c == capacity)
signalNotFull();
return x;
}
use of java.util.concurrent.locks.ReentrantLock in project sling by apache.
the class JspRuntimeContext method getTagFileLoadingLock.
/**
* Returns and optionally creates a lock to load a tag file.
*/
private Lock getTagFileLoadingLock(final String tagFilePath) {
Lock lock = tagFileLoadingLocks.get(tagFilePath);
if (lock == null) {
lock = new ReentrantLock();
final Lock existingLock = tagFileLoadingLocks.putIfAbsent(tagFilePath, lock);
if (existingLock != null) {
lock = existingLock;
}
}
return lock;
}
Aggregations