Java 类java.util.concurrent.locks.AbstractQueuedSynchronizer 实例源码

项目:ignite    文件:GridCacheLockImpl.java   
/** {@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);
    }
}
项目:ignite    文件:GridCacheLockImpl.java   
/** {@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);
    }
}
项目:openjdk-jdk10    文件:AbstractQueuedSynchronizerTest.java   
/**
 * 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());
}
项目:openjdk-jdk10    文件:AbstractQueuedSynchronizerTest.java   
/**
 * 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)));
}
项目:openjdk-jdk10    文件:AbstractQueuedSynchronizerTest.java   
/**
 * 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());
}
项目:openjdk-jdk10    文件:AbstractQueuedSynchronizerTest.java   
/**
 * 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());
}
项目:openjdk9    文件:AbstractQueuedSynchronizerTest.java   
/**
 * 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());
}
项目:openjdk9    文件:AbstractQueuedSynchronizerTest.java   
/**
 * 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)));
}
项目:openjdk9    文件:AbstractQueuedSynchronizerTest.java   
/**
 * 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());
}
项目:openjdk9    文件:AbstractQueuedSynchronizerTest.java   
/**
 * 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());
}
项目:error-prone    文件:NestedClassTemplateExample.java   
ConditionObject example(AbstractQueuedSynchronizer sync) {
  return null;
}
项目:error-prone    文件:NestedClassTemplate.java   
@BeforeTemplate
public ConditionObject before(AbstractQueuedSynchronizer sync) {
  return sync.new ConditionObject();
}
项目:error-prone    文件:NestedClassTemplate.java   
@AfterTemplate
public ConditionObject after(AbstractQueuedSynchronizer sync) {
  return null;
}
项目:error-prone    文件:NestedClassTemplateExample.java   
ConditionObject example(AbstractQueuedSynchronizer sync) {
  return sync.new ConditionObject();
}
项目:java-thread-sanitizer    文件:EventListener.java   
public static void juclAQS_releaseShared(AbstractQueuedSynchronizer owner, int arg, long pc) {
  writer.writeEvent(EventType.SIGNAL, tid(), pc, System.identityHashCode(owner), 0);
}
项目:java-thread-sanitizer    文件:EventListener.java   
public static void juclAQS_acquireSharedInterruptibly(AbstractQueuedSynchronizer owner,
                                                      int arg, long pc){
  writer.writeEvent(EventType.WAIT, tid(), pc, System.identityHashCode(owner), 0);
}
项目:java-thread-sanitizer    文件:EventListener.java   
public static void juclAQS_acquireShared(AbstractQueuedSynchronizer owner, int arg, long pc){
  writer.writeEvent(EventType.WAIT, tid(), pc, System.identityHashCode(owner), 0);
}
项目:java-thread-sanitizer    文件:EventListener.java   
public static void juclAQS_tryAcquireSharedNanos(AbstractQueuedSynchronizer owner,
                                                 int arg, long nanos, boolean result, long pc) {
  if (result) {
    writer.writeEvent(EventType.WAIT, tid(), pc, System.identityHashCode(owner), 0);
  }
}