@Override public boolean acquire(long delay) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); boolean success = false; if (delay <= 0) return attempt(); Semaphore semaphore = createSemaphore(); if (semaphore == null) return true; if (DEBUG) System.out.println("[" + Thread.currentThread() + "] Operation waiting to be executed... " + this); //$NON-NLS-1$ //$NON-NLS-2$ success = doAcquire(semaphore, delay); manager.resumeSuspendedLocks(Thread.currentThread()); if (DEBUG) System.out.println("[" + Thread.currentThread() + //$NON-NLS-1$ (success ? "] Operation started... " : "] Operation timed out... ") + this); //$NON-NLS-1$ //$NON-NLS-2$ //} if (!success && Thread.interrupted()) throw new InterruptedException(); return success; }
public boolean acquire(long delay) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); boolean success = false; if (delay <= 0) return attempt(); Semaphore semaphore = createSemaphore(); if (semaphore == null) return true; if (DEBUG) System.out.println("[" + Thread.currentThread() + "] Operation waiting to be executed... " + this); //$NON-NLS-1$ //$NON-NLS-2$ success = doAcquire(semaphore, delay); manager.resumeSuspendedLocks(Thread.currentThread()); if (DEBUG) System.out.println("[" + Thread.currentThread() + //$NON-NLS-1$ (success ? "] Operation started... " : "] Operation timed out... ") + this); //$NON-NLS-1$ //$NON-NLS-2$ //} return success; }
public boolean acquire(long delay) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); boolean success = false; if (delay <= 0) return attempt(); Semaphore semaphore = createSemaphore(); if (semaphore == null) return true; if (DEBUG) System.out.println("[" + Thread.currentThread() + "] Operation waiting to be executed... " + this); //$NON-NLS-1$ //$NON-NLS-2$ success = doAcquire(semaphore, delay); manager.resumeSuspendedLocks(Thread.currentThread()); if (DEBUG) System.out.println("[" + Thread.currentThread() + //$NON-NLS-1$ (success ? "] Operation started... " : "] Operation timed out... ") + this); //$NON-NLS-1$ //$NON-NLS-2$ //} if (!success && Thread.interrupted()) throw new InterruptedException(); return success; }
@Override public boolean acquire(long delay) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); boolean success = false; if (delay <= 0) return attempt(); Semaphore semaphore = createSemaphore(); if (semaphore == null) return true; if (DEBUG) System.out.println("[" + Thread.currentThread() + "] Operation waiting to be executed... " + this); //$NON-NLS-1$ //$NON-NLS-2$ success = doAcquire(semaphore, delay); manager.resumeSuspendedLocks(Thread.currentThread()); if (DEBUG) System.out.println("[" + Thread.currentThread() + //$NON-NLS-1$ (success ? "] Operation started... " : "] Operation timed out... ") + this); //$NON-NLS-1$ //$NON-NLS-2$ //} if (!success && Thread.interrupted()) throw new InterruptedException(); return success; }
/** * Reports that this thread was blocked, but is no longer blocked and is able * to proceed. * @param monitor The monitor to report unblocking to. */ private void waitEnd(IProgressMonitor monitor) { final LockManager lockManager = manager.getLockManager(); final Thread currentThread = Thread.currentThread(); if (isRunning()) { lockManager.addLockThread(currentThread, getRule()); //need to re-acquire any locks that were suspended while this thread was blocked on the rule lockManager.resumeSuspendedLocks(currentThread); } else { //tell lock manager that this thread gave up waiting lockManager.removeLockWaitThread(currentThread, getRule()); } }
/** * Reports that this thread was blocked, but is no longer blocked and is able * to proceed. * @param monitor The monitor to report unblocking to. */ static private void waitEnd(ThreadJob threadJob, boolean updateLockManager, IProgressMonitor monitor) { if (updateLockManager) { final LockManager lockManager = manager.getLockManager(); final Thread currentThread = Thread.currentThread(); if (threadJob.isRunning()) { lockManager.addLockThread(currentThread, threadJob.getRule()); //need to re-acquire any locks that were suspended while this thread was blocked on the rule lockManager.resumeSuspendedLocks(currentThread); } else { //tell lock manager that this thread gave up waiting lockManager.removeLockWaitThread(currentThread, threadJob.getRule()); } } if (threadJob.isBlocked) { threadJob.isBlocked = false; manager.reportUnblocked(monitor); } }
/** * Reports that this thread was blocked, but is no longer blocked and is able * to proceed. * @param monitor The monitor to report unblocking to. */ static private void waitEnd(ThreadJob threadJob, boolean updateLockManager, IProgressMonitor monitor) { if (updateLockManager) { final LockManager lockManager = manager.getLockManager(); final Thread currentThread = Thread.currentThread(); if (threadJob.isRunning()) { lockManager.addLockThread(currentThread, threadJob.getRule()); //need to re-acquire any locks that were suspended while this thread was blocked on the rule lockManager.resumeSuspendedLocks(currentThread); } else { //tell lock manager that this thread gave up waiting lockManager.removeLockWaitThread(currentThread, threadJob.getRule()); } } if (threadJob.isBlocked) { threadJob.isBlocked = false; manager.reportUnblocked(monitor); } }
/** * Reports that this thread was blocked, but is no longer blocked and is able * to proceed. * @param monitor The monitor to report unblocking to. */ static private void waitEnd(ThreadJob threadJob, boolean updateLockManager, IProgressMonitor monitor) { if (updateLockManager) { final LockManager lockManager = manager.getLockManager(); final Thread currentThread = Thread.currentThread(); if (threadJob.isRunning()) { lockManager.addLockThread(currentThread, threadJob.getRule()); //need to re-acquire any locks that were suspended while this thread was blocked on the rule lockManager.resumeSuspendedLocks(currentThread); } else { //tell lock manager that this thread gave up waiting lockManager.removeLockWaitThread(currentThread, threadJob.getRule()); } } if (threadJob.isBlocked) { threadJob.isBlocked = false; manager.reportUnblocked(monitor); } }