/** * Returns null if acquired and a Semaphore object otherwise. If a * waiting semaphore already exists for this thread, it will be returned, * otherwise a new semaphore will be created, enqueued, and returned. */ private synchronized Semaphore createSemaphore() { return attempt() ? null : enqueue(new Semaphore(Thread.currentThread())); }
@Override public void done(IJobChangeEvent event) { barrier.release(); } };
manager.addLockWaitThread(currentThread, this); try { success = semaphore.acquire(delay); } catch (InterruptedException e) { if (DEBUG)
/** * We have finished waiting on the given semaphore. Update the operation queue according * to whether we succeeded in obtaining the lock. * * @param semaphore The semaphore that we waited on * @param acquired <code>true</code> if we successfully acquired the semaphore, and <code>false</code> otherwise * @return whether the lock was successfully obtained */ private synchronized boolean updateOperationQueue(Semaphore semaphore, boolean acquired) { // Bug 311863 - Semaphore may have been released concurrently, so check again before discarding it if (!acquired) acquired = semaphore.attempt(); if (acquired) { depth++; updateCurrentOperation(); } else { removeFromQueue(semaphore); manager.removeLockWaitThread(Thread.currentThread(), this); } return acquired; }
manager.addLockWaitThread(currentThread, this); try { success = semaphore.acquire(delay); } catch (InterruptedException e) { if (DEBUG)
/** * We have finished waiting on the given semaphore. Update the operation queue according * to whether we succeeded in obtaining the lock. * * @param semaphore The semaphore that we waited on * @param acquired <code>true</code> if we successfully acquired the semaphore, and <code>false</code> otherwise * @return whether the lock was successfully obtained */ private synchronized boolean updateOperationQueue(Semaphore semaphore, boolean acquired) { // Bug 311863 - Semaphore may have been released concurrently, so check again before discarding it if (!acquired) acquired = semaphore.attempt(); if (acquired) { depth++; updateCurrentOperation(); } else { removeFromQueue(semaphore); manager.removeLockWaitThread(Thread.currentThread(), this); } return acquired; }
@Override public void done(IJobChangeEvent event) { barrier.release(); } };
/** * Returns null if acquired and a Semaphore object otherwise. If a * waiting semaphore already exists for this thread, it will be returned, * otherwise a new semaphore will be created, enqueued, and returned. */ private synchronized Semaphore createSemaphore() { return attempt() ? null : enqueue(new Semaphore(Thread.currentThread())); }
manager.addLockWaitThread(currentThread, this); try { success = semaphore.acquire(delay); } catch (InterruptedException e) { if (DEBUG)
/** * We have finished waiting on the given semaphore. Update the operation queue according * to whether we succeeded in obtaining the lock. * * @param semaphore The semaphore that we waited on * @param acquired <code>true</code> if we successfully acquired the semaphore, and <code>false</code> otherwise * @return whether the lock was successfully obtained */ private synchronized boolean updateOperationQueue(Semaphore semaphore, boolean acquired) { // Bug 311863 - Semaphore may have been released concurrently, so check again before discarding it if (!acquired) acquired = semaphore.attempt(); if (acquired) { depth++; updateCurrentOperation(); } else { removeFromQueue(semaphore); manager.removeLockWaitThread(Thread.currentThread(), this); } return acquired; }
public void done(IJobChangeEvent event) { barrier.release(); } };
/** * Returns null if acquired and a Semaphore object otherwise. If a * waiting semaphore already exists for this thread, it will be returned, * otherwise a new semaphore will be created, enqueued, and returned. */ private synchronized Semaphore createSemaphore() { return attempt() ? null : enqueue(new Semaphore(Thread.currentThread())); }
manager.addLockWaitThread(Thread.currentThread(), this); try { success = semaphore.acquire(delay); } catch (InterruptedException e) { if (DEBUG)
public void done(IJobChangeEvent event) { barrier.release(); } };
/** * Returns null if acquired and a Semaphore object otherwise. If a * waiting semaphore already exists for this thread, it will be returned, * otherwise a new semaphore will be created, enqueued, and returned. */ private synchronized Semaphore createSemaphore() { return attempt() ? null : enqueue(new Semaphore(Thread.currentThread())); }
/** * Releases this lock from the thread that used to own it. * Grants this lock to the next thread in the queue. */ private synchronized void doRelease() { //notify hook manager.aboutToRelease(); depth = 0; Semaphore next = (Semaphore) operations.peek(); setCurrentOperationThread(null); if (next != null) next.release(); }