@Override public void unlock() { try { super.unlock(); } finally { lockStateChanged(readWriteLock); } } }
@Override public void lock() { aboutToAcquire(readWriteLock); try { super.lock(); } finally { lockStateChanged(readWriteLock); } }
@Override public long awaitNanos(long nanosTimeout) throws InterruptedException { lock.lock(); try { return condition.awaitNanos(nanosTimeout); } finally { lock.unlock(); } }
@Override public void awaitUninterruptibly() { lock.lock(); try { condition.awaitUninterruptibly(); } finally { lock.unlock(); } }
@Override public boolean awaitUntil(Date deadline) throws InterruptedException { lock.lock(); try { return condition.awaitUntil(deadline); } finally { lock.unlock(); } }
BlockingFlowableIterator(int batchSize) { this.queue = new SpscArrayQueue<T>(batchSize); this.batchSize = batchSize; this.limit = batchSize - (batchSize >> 2); this.lock = new ReentrantLock(); this.condition = lock.newCondition(); }
@Override public void lock() { aboutToAcquire(readWriteLock); try { super.lock(); } finally { lockStateChanged(readWriteLock); } }
/** * Enters this monitor if it is possible to do so immediately. Does not block. * * <p><b>Note:</b> This method disregards the fairness setting of this monitor. * * @return whether the monitor was entered */ public boolean tryEnter() { return lock.tryLock(); }
/** * Returns whether the current thread is occupying this monitor (has entered more times than it * has left). */ public boolean isOccupiedByCurrentThread() { return lock.isHeldByCurrentThread(); }
@Override public void lockInterruptibly() throws InterruptedException { aboutToAcquire(this); try { super.lockInterruptibly(); } finally { lockStateChanged(this); } }
@Override public boolean tryLock() { aboutToAcquire(readWriteLock); try { return super.tryLock(); } finally { lockStateChanged(readWriteLock); } }
@Override public boolean tryLock() { aboutToAcquire(readWriteLock); try { return super.tryLock(); } finally { lockStateChanged(readWriteLock); } }
/** * Returns an estimate of the number of threads waiting to enter this monitor. The value is only * an estimate because the number of threads may change dynamically while this method traverses * internal data structures. This method is designed for use in monitoring of the system state, * not for synchronization control. */ public int getQueueLength() { return lock.getQueueLength(); }
BlockingObservableIterator(int batchSize) { this.queue = new SpscLinkedArrayQueue<T>(batchSize); this.lock = new ReentrantLock(); this.condition = lock.newCondition(); }