java.util.concurrent.locks.AbstractQueuedSynchronizer Java Examples
The following examples show how to use
java.util.concurrent.locks.AbstractQueuedSynchronizer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GridCacheLockImpl.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public boolean hasWaiters(IgniteCondition condition) { try { initializeReentrantLock(); AbstractQueuedSynchronizer.ConditionObject c = sync.conditionMap.get(condition.name()); if (c == null) throw new IllegalArgumentException(); return sync.hasWaiters(c); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
Example #2
Source File: GridCacheLockImpl.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public int getWaitQueueLength(IgniteCondition condition) { try { initializeReentrantLock(); AbstractQueuedSynchronizer.ConditionObject c = sync.conditionMap.get(condition.name()); if (c == null) throw new IllegalArgumentException(); return sync.getWaitQueueLength(c); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
Example #3
Source File: AbstractQueuedSynchronizerTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Spin-waits until sync.isQueued(t) becomes true. */ void waitForQueuedThread(AbstractQueuedSynchronizer sync, Thread t) { long startTime = System.nanoTime(); while (!sync.isQueued(t)) { if (millisElapsedSince(startTime) > LONG_DELAY_MS) throw new AssertionFailedError("timed out"); Thread.yield(); } assertTrue(t.isAlive()); }
Example #4
Source File: AbstractQueuedSynchronizerTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Checks that sync has exactly the given queued threads. */ void assertHasQueuedThreads(AbstractQueuedSynchronizer sync, Thread... expected) { Collection<Thread> actual = sync.getQueuedThreads(); assertEquals(expected.length > 0, sync.hasQueuedThreads()); assertEquals(expected.length, sync.getQueueLength()); assertEquals(expected.length, actual.size()); assertEquals(expected.length == 0, actual.isEmpty()); assertEquals(new HashSet<Thread>(actual), new HashSet<Thread>(Arrays.asList(expected))); }
Example #5
Source File: AbstractQueuedSynchronizerTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Checks that sync has exactly the given (exclusive) queued threads. */ void assertHasExclusiveQueuedThreads(AbstractQueuedSynchronizer sync, Thread... expected) { assertHasQueuedThreads(sync, expected); assertEquals(new HashSet<Thread>(sync.getExclusiveQueuedThreads()), new HashSet<Thread>(sync.getQueuedThreads())); assertEquals(0, sync.getSharedQueuedThreads().size()); assertTrue(sync.getSharedQueuedThreads().isEmpty()); }
Example #6
Source File: AbstractQueuedSynchronizerTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Checks that sync has exactly the given (shared) queued threads. */ void assertHasSharedQueuedThreads(AbstractQueuedSynchronizer sync, Thread... expected) { assertHasQueuedThreads(sync, expected); assertEquals(new HashSet<Thread>(sync.getSharedQueuedThreads()), new HashSet<Thread>(sync.getQueuedThreads())); assertEquals(0, sync.getExclusiveQueuedThreads().size()); assertTrue(sync.getExclusiveQueuedThreads().isEmpty()); }
Example #7
Source File: AbstractQueuedSynchronizerTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Spin-waits until sync.isQueued(t) becomes true. */ void waitForQueuedThread(AbstractQueuedSynchronizer sync, Thread t) { long startTime = System.nanoTime(); while (!sync.isQueued(t)) { if (millisElapsedSince(startTime) > LONG_DELAY_MS) throw new AssertionFailedError("timed out"); Thread.yield(); } assertTrue(t.isAlive()); }
Example #8
Source File: AbstractQueuedSynchronizerTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Checks that sync has exactly the given queued threads. */ void assertHasQueuedThreads(AbstractQueuedSynchronizer sync, Thread... expected) { Collection<Thread> actual = sync.getQueuedThreads(); assertEquals(expected.length > 0, sync.hasQueuedThreads()); assertEquals(expected.length, sync.getQueueLength()); assertEquals(expected.length, actual.size()); assertEquals(expected.length == 0, actual.isEmpty()); assertEquals(new HashSet<Thread>(actual), new HashSet<Thread>(Arrays.asList(expected))); }
Example #9
Source File: AbstractQueuedSynchronizerTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Checks that sync has exactly the given (exclusive) queued threads. */ void assertHasExclusiveQueuedThreads(AbstractQueuedSynchronizer sync, Thread... expected) { assertHasQueuedThreads(sync, expected); assertEquals(new HashSet<Thread>(sync.getExclusiveQueuedThreads()), new HashSet<Thread>(sync.getQueuedThreads())); assertEquals(0, sync.getSharedQueuedThreads().size()); assertTrue(sync.getSharedQueuedThreads().isEmpty()); }
Example #10
Source File: AbstractQueuedSynchronizerTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Checks that sync has exactly the given (shared) queued threads. */ void assertHasSharedQueuedThreads(AbstractQueuedSynchronizer sync, Thread... expected) { assertHasQueuedThreads(sync, expected); assertEquals(new HashSet<Thread>(sync.getSharedQueuedThreads()), new HashSet<Thread>(sync.getQueuedThreads())); assertEquals(0, sync.getExclusiveQueuedThreads().size()); assertTrue(sync.getExclusiveQueuedThreads().isEmpty()); }