当前位置: 首页>>代码示例>>Java>>正文


Java State.STARTING属性代码示例

本文整理汇总了Java中com.google.common.util.concurrent.Service.State.STARTING属性的典型用法代码示例。如果您正苦于以下问题:Java State.STARTING属性的具体用法?Java State.STARTING怎么用?Java State.STARTING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.common.util.concurrent.Service.State的用法示例。


在下文中一共展示了State.STARTING属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCustomScheduler_deadlock

public void testCustomScheduler_deadlock() throws InterruptedException, BrokenBarrierException {
  final CyclicBarrier inGetNextSchedule = new CyclicBarrier(2);
  // This will flakily deadlock, so run it multiple times to increase the flake likelihood
  for (int i = 0; i < 1000; i++) {
    Service service = new AbstractScheduledService() {
      @Override protected void runOneIteration() {}
      @Override protected Scheduler scheduler() {
        return new CustomScheduler() {
          @Override protected Schedule getNextSchedule() throws Exception {
            if (state() != State.STARTING) {
              inGetNextSchedule.await();
              Thread.yield();
              throw new RuntimeException("boom");
            }
            return new Schedule(0, TimeUnit.NANOSECONDS);
          }
        };
      }
    };
    service.startAsync().awaitRunning();
    inGetNextSchedule.await();
    service.stopAsync();
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:24,代码来源:AbstractScheduledServiceTest.java

示例2: enqueueStoppingEvent

private void enqueueStoppingEvent(final State from) {
  if (from == State.STARTING) {
    listeners.enqueue(STOPPING_FROM_STARTING_EVENT);
  } else if (from == State.RUNNING) {
    listeners.enqueue(STOPPING_FROM_RUNNING_EVENT);
  } else {
    throw new AssertionError();
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:AbstractService.java

示例3: stopping

@Override public synchronized void stopping(State from) {
  assertEquals(from, Iterables.getLast(stateHistory));
  stateHistory.add(State.STOPPING);
  if (from == State.STARTING) {
    try {
      service.awaitRunning();
      fail();
    } catch (IllegalStateException expected) {
      assertNull(expected.getCause());
      assertTrue(expected.getMessage().equals(
          "Expected the service " + service + " to be RUNNING, but was STOPPING"));
    }
  }
  assertNotSame(from, service.state());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:15,代码来源:AbstractServiceTest.java

示例4: stopping

@GuardedBy("monitor")
private void stopping(final State from) {
  if (from == State.STARTING) {
    STOPPING_FROM_STARTING_CALLBACK.enqueueOn(listeners);
  } else if (from == State.RUNNING) {
    STOPPING_FROM_RUNNING_CALLBACK.enqueueOn(listeners);
  } else {
    throw new AssertionError();
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:10,代码来源:AbstractService.java

示例5: isStarting

@Override
public final boolean isStarting() {
    return service.state() == State.STARTING;
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:4,代码来源:BaseEngineModule.java


注:本文中的com.google.common.util.concurrent.Service.State.STARTING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。