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


Java Timer.newTimeout方法代码示例

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


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

示例1: testTryWithResourcesShouldCloseAllClustersButNotTimerIfProvided

import io.netty.util.Timer; //导入方法依赖的package包/类
@Test
public void testTryWithResourcesShouldCloseAllClustersButNotTimerIfProvided() throws Exception {
  EventLoopGroup eventLoop;
  Timer timer = new HashedWheelTimer();

  try (Server server = Server.builder().withTimer(timer).build()) {
    // Do nothing here, since this is a unit test, we don't want to create any inet sockets
    // which is what Server does by default.
    eventLoop = server.eventLoopGroup;
  }

  // event loop should have been closed since a custom one was not provided.
  assertThat(eventLoop.isShutdown()).isTrue();
  // timer should not have been closed since a custom one was provided.
  timer.newTimeout(
      timeout -> {
        // noop
      },
      1,
      TimeUnit.SECONDS);
  timer.stop();
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:23,代码来源:ServerTest.java

示例2: testTryWithResourcesShouldCloseAllResources

import io.netty.util.Timer; //导入方法依赖的package包/类
@Test
public void testTryWithResourcesShouldCloseAllResources() throws Exception {
  EventLoopGroup eventLoop;
  Timer timer;

  try (Server server = Server.builder().build()) {
    // Do nothing here, since this is a unit test, we don't want to create any inet sockets
    // which is what Server does by default.
    eventLoop = server.eventLoopGroup;
    timer = server.timer;
  }

  // event loop should have been closed since a custom one was not provided.
  assertThat(eventLoop.isShutdown()).isTrue();
  // timer should have since a custom one was not provided.
  try {
    timer.newTimeout(
        timeout -> {
          // noop
        },
        1,
        TimeUnit.SECONDS);
    fail("Expected IllegalStateException");
  } catch (IllegalStateException ise) {
    // expected
  }
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:28,代码来源:ServerTest.java

示例3: tryInterruptInterruptsWaitingThreads

import io.netty.util.Timer; //导入方法依赖的package包/类
@Test(expected = InterruptedException.class)
public void tryInterruptInterruptsWaitingThreads() throws Exception {
    final InterruptingSemaphore interruptingSemaphore = new InterruptingSemaphore(0);

    final Timer timer = new HashedWheelTimer();

    timer.newTimeout(new TimerTask() {
        @Override
        public void run(Timeout timeout) throws Exception {
            interruptingSemaphore.tryInterrupt();
        }
    }, 10, TimeUnit.MILLISECONDS);
    interruptingSemaphore.acquire();
}
 
开发者ID:spapageo,项目名称:jannel,代码行数:15,代码来源:InterruptingSemaphoreTest.java

示例4: init

import io.netty.util.Timer; //导入方法依赖的package包/类
/**
 * Initialization for plugin called by the OFSwitchHandshakeHandler
 *
 * @param state the current state of the OFSwitchHandshakeHandler
 * @param sw the current switch of the OFSwitchHandshakeHandler
 */
final void init(WaitAppHandshakeState state, IOFSwitch sw, Timer timer) {
    this.state = state;
    this.sw = sw;
    this.timeout = timer.newTimeout(new PluginTimeoutTask(), timeoutS, TimeUnit.SECONDS);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:12,代码来源:OFSwitchAppHandshakePlugin.java


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