java.util.concurrent.CyclicBarrier.getNumberWaiting()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中java.util.concurrent.CyclicBarrier.getNumberWaiting()方法的一些代码示例,展示了CyclicBarrier.getNumberWaiting()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CyclicBarrier.getNumberWaiting()方法的具体详情如下:
包路径:java.util.concurrent.CyclicBarrier
类名称:CyclicBarrier
方法名:getNumberWaiting

CyclicBarrier.getNumberWaiting介绍

[英]Returns the number of parties currently waiting at the barrier. This method is primarily useful for debugging and assertions.
[中]返回当前在屏障处等待的参与方数。此方法主要用于调试和断言。

代码示例

代码示例来源:origin: apache/ignite

/**
 * Assert that on barrier waiting one thread.
 *
 * @throws IgniteInterruptedCheckedException In case of failure.
 */
private void assertWaitingOnBarrier() throws IgniteInterruptedCheckedException {
  Assert.assertTrue("Still waiting " + barrier.getNumberWaiting() + " parties",
    GridTestUtils.waitForCondition(() -> barrier.getNumberWaiting() == 1, TIMEOUT_IN_MS));
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
  super.afterTest();
  Assert.assertEquals(0, barrier.getNumberWaiting());
  assertNoRunningQueries();
}

代码示例来源:origin: apache/ignite

while (barrier.getNumberWaiting() != threadCnt)
  Thread.sleep(1);

代码示例来源:origin: apache/ignite

while (restartBarrier.getNumberWaiting() != producerCnt && ex.get() == null)
  U.sleep(10);

代码示例来源:origin: apache/ignite

/**
 * Check tracking running queries for Select.
 *
 * @throws Exception Exception in case of failure.
 */
@Test
public void testQueries() throws Exception {
  newBarrier(3);
  IgniteCache<Object, Object> cache = ignite.cache(DEFAULT_CACHE_NAME);
  IgniteInternalFuture<List<List<?>>> fut1 = GridTestUtils.runAsync(() -> cache.query(new SqlFieldsQuery(
    "SELECT * FROM /* comment */ Integer WHERE 1 = 1")).getAll());
  IgniteInternalFuture<List<Cache.Entry<Integer, Integer>>> fut2 = GridTestUtils.runAsync(() -> cache.query(
    new SqlQuery<Integer, Integer>(Integer.class, "FROM /* comment */ Integer WHERE 1 = 1"))
    .getAll());
  Assert.assertTrue(GridTestUtils.waitForCondition(
    () -> barrier.getNumberWaiting() == 2, TIMEOUT_IN_MS));
  Collection<GridRunningQueryInfo> runningQueries = ignite.context().query().runningQueries(-1);
  assertEquals(2, runningQueries.size());
  for (GridRunningQueryInfo info : runningQueries)
    assertTrue("Failed to find comment in query: " + info.query(), info.query().contains("/* comment */"));
  assertNoRunningQueries(ignite);
  awaitTimeouted();
  fut1.get(TIMEOUT_IN_MS);
  fut2.get(TIMEOUT_IN_MS);
}

代码示例来源:origin: org.jboss.arquillian.container/arquillian-jsr88-remote-1.2

void moduleStarted(boolean status)
{
 moduleStarted = status;
 if (PROGRESS_BARRIER.getNumberWaiting() > 0)
 {
   try
   {
    PROGRESS_BARRIER.await();
   }
   catch (Exception e)
   {
    throw new RuntimeException("Failed to report module as " + (status ? "started" : "shutdown"), e);
   }
 }
}

代码示例来源:origin: zeebe-io/zeebe

public void workUntilDone() {
  try {
   barrier.await(); // work at least 1 full cycle until the runner becomes idle after having been
   while (barrier.getNumberWaiting() < 1) {
    // spin until thread is idle again
    Thread.yield();
   }
  } catch (InterruptedException | BrokenBarrierException e) {
   LangUtil.rethrowUnchecked(e);
  }
 }
}

代码示例来源:origin: io.zeebe/zb-util

public void workUntilDone() {
  try {
   barrier.await(); // work at least 1 full cycle until the runner becomes idle after having been
   while (barrier.getNumberWaiting() < 1) {
    // spin until thread is idle again
    Thread.yield();
   }
  } catch (InterruptedException | BrokenBarrierException e) {
   LangUtil.rethrowUnchecked(e);
  }
 }
}

代码示例来源:origin: Nepxion/Thunder

@Override
  public void run() {
    for (int i = 0; i < 100; i++) {
      try {
        userService.getUsers();
        // User user1 = userService.getUser("Zhangsan", 30);
        // LOG.info("客户端-同步调用结果:返回值=User1 name={}, address={}, phone={}", user1.getName(), user1.getAddress(), user1.getPhone());
      } catch (Exception e) {
        LOG.error("::::userService.getUsers():::", e);
      }
    }
    LOG.info("客户端-计数器:" + barrier.getNumberWaiting());
    try {
      barrier.await();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
});

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Unblocks the optionally blocked thread.
 * 
 * @throws IOException
 * 
 * @see #block()
 */
public void unblock() throws IOException {
  if (Context.getCurrentLogger().isLoggable(Level.FINEST)) {
    Context.getCurrentLogger().log(
        Level.FINEST,
        "Calling thread about to unblock the NIO selection registration. Timeout: "
            + TimeUnit.MILLISECONDS
                .toMillis(IoUtils.TIMEOUT_MS)
            + " ms. Waiting: "
            + this.barrier.getNumberWaiting());
  }
  try {
    this.barrier.await(IoUtils.TIMEOUT_MS, TimeUnit.MILLISECONDS);
  } catch (Exception e) {
    Context.getCurrentLogger()
        .log(Level.WARNING,
            "Unable to unblock the waiting thread at the cyclic barrier",
            e);
    IOException ioe = new IOException(
        "Unable to unblock the waiting thread at the cyclic barrier.");
    ioe.initCause(e);
    throw ioe;
  }
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Unblocks the optionally blocked thread.
 * 
 * @throws IOException
 * 
 * @see #block()
 */
public void unblock() throws IOException {
  if (Context.getCurrentLogger().isLoggable(Level.FINEST)) {
    Context.getCurrentLogger().log(
        Level.FINEST,
        "Calling thread about to unblock the NIO selection registration. Timeout: "
            + TimeUnit.MILLISECONDS
                .toMillis(/*IoUtils.TIMEOUT_MS*/60000)
            + " ms. Waiting: "
            + this.barrier.getNumberWaiting());
  }
  try {
    this.barrier.await(/*IoUtils.TIMEOUT_MS*/60000, TimeUnit.MILLISECONDS);
  } catch (Exception e) {
    Context.getCurrentLogger()
        .log(Level.WARNING,
            "Unable to unblock the waiting thread at the cyclic barrier",
            e);
    IOException ioe = new IOException(
        "Unable to unblock the waiting thread at the cyclic barrier.");
    ioe.initCause(e);
    throw ioe;
  }
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

.toMillis(/*IoUtils.TIMEOUT_MS*/60000)
+ " ms. Waiting: "
+ this.barrier.getNumberWaiting());

代码示例来源:origin: org.restlet.osgi/org.restlet

.toMillis(IoUtils.TIMEOUT_MS)
+ " ms. Waiting: "
+ this.barrier.getNumberWaiting());

代码示例来源:origin: bluestreak01/questdb

JournalMetadata<?> metadata = meta[rnd.nextPositiveInt() % readerCount];
try (Journal<?> ignored = rf.reader(metadata)) {
  if (metadata == meta[readerCount - 1] && barrier.getNumberWaiting() > 0) {
    barrier.await();

代码示例来源:origin: bluestreak01/questdb

TestUtils.assertEquals(expectedRows[index], sink);
if (name.equals(names[readerCount - 1]) && barrier.getNumberWaiting() > 0) {
  barrier.await();

相关文章