/** * Returns whether any threads are waiting to enter this monitor. Note that because cancellations * may occur at any time, a {@code true} return does not guarantee that any other thread will ever * enter this monitor. This method is designed primarily for use in monitoring of the system * state. */ public boolean hasQueuedThreads() { return lock.hasQueuedThreads(); }
/** * Returns whether any threads are waiting to enter this monitor. Note that because cancellations * may occur at any time, a {@code true} return does not guarantee that any other thread will ever * enter this monitor. This method is designed primarily for use in monitoring of the system * state. */ public boolean hasQueuedThreads() { return lock.hasQueuedThreads(); }
/** * Returns whether any threads are waiting to enter this monitor. Note that because cancellations * may occur at any time, a {@code true} return does not guarantee that any other thread will ever * enter this monitor. This method is designed primarily for use in monitoring of the system * state. */ public boolean hasQueuedThreads() { return lock.hasQueuedThreads(); }
/** * Returns whether any threads are waiting to enter this monitor. Note that because cancellations * may occur at any time, a {@code true} return does not guarantee that any other thread will ever * enter this monitor. This method is designed primarily for use in monitoring of the system * state. */ public boolean hasQueuedThreads() { return lock.hasQueuedThreads(); }
/** * Returns whether there are threads waiting for read access to the * Guacamole instruction stream. * * @return true if threads are waiting for read access the Guacamole * instruction stream, false otherwise. */ @Override public boolean hasQueuedReaderThreads() { return readerLock.hasQueuedThreads(); }
@Override public boolean inUse() { return super.isLocked() || super.hasQueuedThreads(); }
@Override public boolean hasQueuedWriterThreads() { return writerLock.hasQueuedThreads(); }
@Override public boolean inUse() { return super.isLocked() || super.hasQueuedThreads(); }
protected void releaseAndCleanLock(Long id, RuntimeEngine runtime) { if (id != null) { ReentrantLock lock = engineLocks.get(id); if (lock != null) { if (!lock.hasQueuedThreads()) { logger.debug("Removing lock {} from list as non is waiting for it by {}", lock, runtime); engineLocks.remove(id); } if (lock.isHeldByCurrentThread()) { lock.unlock(); logger.debug("{} unlocked by {}", lock, runtime); } } } }
protected void createLockOnGetEngine(Long id, RuntimeEngine runtime) { if (!isUseLocking()) { logger.debug("Locking on runtime manager disabled"); return; } if (id != null) { ReentrantLock newLock = new ReentrantLock(); ReentrantLock lock = engineLocks.putIfAbsent(id, newLock); if (lock == null) { lock = newLock; logger.debug("New lock created as it did not exist before"); } else { logger.debug("Lock exists with {} waiting threads", lock.getQueueLength()); } logger.debug("Trying to get a lock {} for {} by {}", lock, id, runtime); lock.lock(); logger.debug("Lock {} taken for {} by {} for waiting threads by {}", lock, id, runtime, lock.hasQueuedThreads()); } }
@Override public void run() { try { tx1 = txMgr.masqueradeAs(msg); } catch (InterruptedException e) { e.printStackTrace(); throw new RuntimeException(e); } msg.process(dm); TXStateProxy existingTx = masqueradeToRollback(); latch.countDown(); await() .until(() -> tx1.getLock().hasQueuedThreads()); rollbackTransaction(existingTx); } });
@Override public void run() { tx1 = txMgr.getHostedTXState(txid); assertNull(tx1); tx1 = txMgr.getOrSetHostedTXState(txid, msg); assertNotNull(tx1); assertTrue(txMgr.getLock(tx1, txid)); latch.countDown(); await() .until(() -> tx1.getLock().hasQueuedThreads()); txMgr.removeHostedTXState(txid); tx2 = txMgr.getOrSetHostedTXState(txid, msg); assertNotNull(tx2); assertTrue(txMgr.getLock(tx2, txid)); tx2.getLock().unlock(); tx1.getLock().unlock(); } });
if (((ReentrantLock) lockInstance).hasQueuedThreads()) {
/** * Returns whether any threads are waiting to enter this monitor. Note that because cancellations * may occur at any time, a {@code true} return does not guarantee that any other thread will ever * enter this monitor. This method is designed primarily for use in monitoring of the system * state. */ public boolean hasQueuedThreads() { return lock.hasQueuedThreads(); }
/** * Returns whether any threads are waiting to enter this monitor. Note that because cancellations * may occur at any time, a {@code true} return does not guarantee that any other thread will ever * enter this monitor. This method is designed primarily for use in monitoring of the system * state. */ public boolean hasQueuedThreads() { return lock.hasQueuedThreads(); }
/** * Returns whether any threads are waiting to enter this monitor. Note that because cancellations * may occur at any time, a {@code true} return does not guarantee that any other thread will ever * enter this monitor. This method is designed primarily for use in monitoring of the system * state. */ public boolean hasQueuedThreads() { return lock.hasQueuedThreads(); }
/** * Returns whether any threads are waiting to enter this monitor. Note that because cancellations * may occur at any time, a {@code true} return does not guarantee that any other thread will ever * enter this monitor. This method is designed primarily for use in monitoring of the system * state. */ public boolean hasQueuedThreads() { return lock.hasQueuedThreads(); }
/** * Returns whether any threads are waiting to enter this monitor. Note that because cancellations * may occur at any time, a {@code true} return does not guarantee that any other thread will ever * enter this monitor. This method is designed primarily for use in monitoring of the system * state. */ public boolean hasQueuedThreads() { return lock.hasQueuedThreads(); }
protected void doSend(byte[] data, int offset, int length, boolean acquire_lock, boolean flush) throws Exception { if(out == null) return; out.writeInt(length); // write the length of the data buffer first out.write(data,offset,length); if(!flush || (acquire_lock && send_lock.hasQueuedThreads())) return; // don't flush as some of the waiting threads will do the flush, or flush is false out.flush(); // may not be very efficient (but safe) }
protected void doSend(byte[] data, int offset, int length, boolean acquire_lock, boolean flush) throws Exception { if(out == null) return; out.writeInt(length); // write the length of the data buffer first out.write(data,offset,length); if(!flush || (acquire_lock && send_lock.hasQueuedThreads())) return; // don't flush as some of the waiting threads will do the flush, or flush is false out.flush(); // may not be very efficient (but safe) }