private void activateDispatcher() { waitingExecutorLock.lock() ; dispatcherActive = true ; waitingExecutorLock.unlock() ; }
private boolean hasFreeExecutor() { waitingExecutorLock.lock() ; try { return (waitingExecutorCount > dispatchedJobs.size()) ; } finally { waitingExecutorLock.unlock() ; } } // return false when interrupted
private boolean hasFreeExecutor() { waitingExecutorLock.lock() ; try { return (waitingExecutorCount > dispatchedJobs.size()) ; } finally { waitingExecutorLock.unlock() ; } }
private void activateDispatcher() { waitingExecutorLock.lock() ; dispatcherActive = true ; waitingExecutorLock.unlock() ; }
/** * Returns whether or not this condition is active so that it can be cleaned * up in a pool. * * @return true if this condition is active otherwise false indicating it * can be deleted. */ public boolean isActive() { if (signalCount == 0 && signalAllCount == 0) { lock.lock(); try { return !listeners.isEmpty(); } finally { lock.unlock(); } } return true; }
public void onSignalAll() { lock.lock(); signalledThread = Thread.currentThread(); try { localCondition.signalAll(); } finally { lock.unlock(); } }
public void await(ConditionListener listener, long timeoutMillis) { // TODO need to timeout stuff... lock.lock(); try { if (!pendingSignals(listener)) { listeners.add(listener); } } finally { lock.unlock(); } }
public void onSignal() { lock.lock(); signalledThread = Thread.currentThread(); try { localCondition.signal(); } finally { lock.unlock(); } }
public void signal() { lock.lock(); try { if (listeners.isEmpty()) { // lets buffer up any missed notifies // in case we're failing over to a new server // instance and the signal() and await() // calls come in out of order signalCount++; } else { ConditionListener listener = (ConditionListener) listeners.removeFirst(); listener.onSignal(id); } } finally { lock.unlock(); } }
/** * Return a Sesame RepositoryConnection to the underlying repository. The connection has auto-commit disabled, * all transaction management must be performed explicitly. * * @return a RepositoryConnection to the underlying Sesame repository. */ @Override @Produces public RepositoryConnection getConnection() throws RepositoryException { restartLock.readLock().lock(); RepositoryConnection connection = repository.getConnection(); return new RepositoryConnectionWrapper(repository,connection) { @Override public void close() throws RepositoryException { super.close(); restartLock.readLock().unlock(); } }; }
/** * Return a Sesame RepositoryConnection to the underlying repository. The connection has auto-commit disabled, * all transaction management must be performed explicitly. * * @return a RepositoryConnection to the underlying Sesame repository. */ @Override @Produces public RepositoryConnection getConnection() throws RepositoryException { restartLock.readLock().lock(); RepositoryConnection connection = repository.getConnection(); return new RepositoryConnectionWrapper(repository,connection) { @Override public void close() throws RepositoryException { super.close(); restartLock.readLock().unlock(); } }; }
boolean submitJob(final Job job) { waitingExecutorLock.lock() ; try { if (hasFreeExecutor()) { dispatchedJobs.add(job) ; waitingExecutorCondition.signal() ; return true ; } } finally { waitingExecutorLock.unlock() ; } return false ; }
boolean submitJob(final Job job) { waitingExecutorLock.lock() ; try { if (hasFreeExecutor()) { dispatchedJobs.add(job) ; waitingExecutorCondition.signal() ; return true ; } } finally { waitingExecutorLock.unlock() ; } return false ; }
public void await() throws InterruptedException { lock.lock(); try { while (true) { // oneway server.await(id, listener, timeout); if (signalledThread == Thread.currentThread()) { signalledThread = null; break; } localCondition.await(); } } finally { lock.unlock(); } }
private void deactivateDispatcher() { waitingExecutorLock.lock() ; try { dispatcherActive = false ; waitingDispatcherCondition.signal() ; waitingExecutorCondition.signalAll() ; } finally { waitingExecutorLock.unlock() ; } }
private void deactivateDispatcher() { waitingExecutorLock.lock() ; try { dispatcherActive = false ; waitingDispatcherCondition.signal() ; waitingExecutorCondition.signalAll() ; } finally { waitingExecutorLock.unlock() ; } }
public boolean await(long timeout, TimeUnit unit) throws InterruptedException { long millis = unit.convert(timeout, TimeUnit.MILLISECONDS); lock.lock(); try { // oneway server.await(id, listener, millis); if (signalledThread == Thread.currentThread()) { signalledThread = null; } else { localCondition.await(); } } finally { lock.unlock(); } return false; }
boolean waitForFreeExecutorThread() { waitingExecutorLock.lock() ; try { waitingDispatcher = true ; if (dispatcherActive) { if (hasFreeExecutor()) { return true ; } else { waitingDispatcherCondition.await() ; return hasFreeExecutor() ; } } } catch (final InterruptedException ie) { } finally { waitingDispatcher = false ; waitingExecutorLock.unlock() ; } return false ; }
/** * Restart the Sesame Service. */ @Override public void restart() { restartLock.writeLock().lock(); try { shutdown(); initialise(); } finally { restartLock.writeLock().unlock(); } }
/** * Restart the Sesame Service. */ @Override public void restart() { restartLock.writeLock().lock(); try { shutdown(); initialise(); } finally { restartLock.writeLock().unlock(); } }