gpt4 book ai didi

org.xnio.XnioExecutor类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 21:26:40 28 4
gpt4 key购买 nike

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

XnioExecutor介绍

[英]An executor with the capability to run timed, cancellable tasks.
[中]能够执行定时、可取消任务的执行者。

代码示例

代码示例来源:origin: wildfly/wildfly

private boolean addInvalidNonce(final Nonce nonce, final XnioExecutor executor) {
  long now = System.currentTimeMillis();
  long invalidBefore = now - firstUseTimeOut;
  long timeTillInvalid = nonce.timeStamp - invalidBefore;
  if (timeTillInvalid > 0) {
    if (invalidNonces.add(nonce.nonce)) {
      executor.executeAfter(new InvalidNonceCleaner(nonce.nonce), timeTillInvalid, TimeUnit.MILLISECONDS);
      return true;
    } else {
      return false;
    }
  } else {
    // So close to expiring any record of this nonce being used could have been cleared so
    // don't take a chance and just say no.
    return false;
  }
}

代码示例来源:origin: wildfly/wildfly

/**
 * Open a unidirectional stream pipe.
 *
 * @param sourceListener the source open listener
 * @param sinkListener the sink open listener
 * @param optionMap the pipe channel configuration
 * @throws java.io.IOException if the pipe could not be created
 * @deprecated Users should prefer the simpler {@link #createHalfDuplexPipe()} instead.
 */
@Deprecated
public void createOneWayPipe(ChannelListener<? super StreamSourceChannel> sourceListener, ChannelListener<? super StreamSinkChannel> sinkListener, final OptionMap optionMap) throws IOException {
  final ChannelPipe<StreamSourceChannel, StreamSinkChannel> pipe = createHalfDuplexPipe();
  final StreamSourceChannel left = pipe.getLeftSide();
  XnioExecutor leftExec = left.getReadThread();
  final StreamSinkChannel right = pipe.getRightSide();
  XnioExecutor rightExec = right.getWriteThread();
  // not unsafe - http://youtrack.jetbrains.net/issue/IDEA-59290
  //noinspection unchecked
  leftExec.execute(ChannelListeners.getChannelListenerTask(left, sourceListener));
  // not unsafe - http://youtrack.jetbrains.net/issue/IDEA-59290
  //noinspection unchecked
  rightExec.execute(ChannelListeners.getChannelListenerTask(right, sinkListener));
}

代码示例来源:origin: wildfly/wildfly

} else {
  if (heartbeatInterval != Integer.MAX_VALUE) {
    this.heartKey = channel.getWriteThread().executeAfter(heartbeatCommand, heartbeatInterval, TimeUnit.MILLISECONDS);

代码示例来源:origin: wildfly/wildfly

/**
 * Open a bidirectional stream pipe.
 *
 * @param leftOpenListener the left-hand open listener
 * @param rightOpenListener the right-hand open listener
 * @param optionMap the pipe channel configuration
 * @throws java.io.IOException if the pipe could not be created
 * @deprecated Users should prefer the simpler {@link #createFullDuplexPipe()} instead.
 */
@Deprecated
public void createPipe(ChannelListener<? super StreamChannel> leftOpenListener, ChannelListener<? super StreamChannel> rightOpenListener, final OptionMap optionMap) throws IOException {
  final ChannelPipe<StreamChannel, StreamChannel> pipe = createFullDuplexPipe();
  final boolean establishWriting = optionMap.get(Options.WORKER_ESTABLISH_WRITING, false);
  final StreamChannel left = pipe.getLeftSide();
  XnioExecutor leftExec = establishWriting ? left.getWriteThread() : left.getReadThread();
  final StreamChannel right = pipe.getRightSide();
  XnioExecutor rightExec = establishWriting ? right.getWriteThread() : right.getReadThread();
  // not unsafe - http://youtrack.jetbrains.net/issue/IDEA-59290
  //noinspection unchecked
  leftExec.execute(ChannelListeners.getChannelListenerTask(left, leftOpenListener));
  // not unsafe - http://youtrack.jetbrains.net/issue/IDEA-59290
  //noinspection unchecked
  rightExec.execute(ChannelListeners.getChannelListenerTask(right, rightOpenListener));
}

代码示例来源:origin: io.undertow/undertow-core

private boolean addInvalidNonce(final Nonce nonce, final XnioExecutor executor) {
  long now = System.currentTimeMillis();
  long invalidBefore = now - firstUseTimeOut;
  long timeTillInvalid = nonce.timeStamp - invalidBefore;
  if (timeTillInvalid > 0) {
    if (invalidNonces.add(nonce.nonce)) {
      executor.executeAfter(new InvalidNonceCleaner(nonce.nonce), timeTillInvalid, TimeUnit.MILLISECONDS);
      return true;
    } else {
      return false;
    }
  } else {
    // So close to expiring any record of this nonce being used could have been cleared so
    // don't take a chance and just say no.
    return false;
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Open a unidirectional stream pipe.
 *
 * @param sourceListener the source open listener
 * @param sinkListener the sink open listener
 * @param optionMap the pipe channel configuration
 * @throws java.io.IOException if the pipe could not be created
 * @deprecated Users should prefer the simpler {@link #createHalfDuplexPipe()} instead.
 */
@Deprecated
public void createOneWayPipe(ChannelListener<? super StreamSourceChannel> sourceListener, ChannelListener<? super StreamSinkChannel> sinkListener, final OptionMap optionMap) throws IOException {
  final ChannelPipe<StreamSourceChannel, StreamSinkChannel> pipe = createHalfDuplexPipe();
  final StreamSourceChannel left = pipe.getLeftSide();
  XnioExecutor leftExec = left.getReadThread();
  final StreamSinkChannel right = pipe.getRightSide();
  XnioExecutor rightExec = right.getWriteThread();
  // not unsafe - http://youtrack.jetbrains.net/issue/IDEA-59290
  //noinspection unchecked
  leftExec.execute(ChannelListeners.getChannelListenerTask(left, sourceListener));
  // not unsafe - http://youtrack.jetbrains.net/issue/IDEA-59290
  //noinspection unchecked
  rightExec.execute(ChannelListeners.getChannelListenerTask(right, sinkListener));
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

private boolean addInvalidNonce(final Nonce nonce, final XnioExecutor executor) {
  long now = System.currentTimeMillis();
  long invalidBefore = now - firstUseTimeOut;
  long timeTillInvalid = nonce.timeStamp - invalidBefore;
  if (timeTillInvalid > 0) {
    if (invalidNonces.add(nonce.nonce)) {
      executor.executeAfter(new InvalidNonceCleaner(nonce.nonce), timeTillInvalid, TimeUnit.MILLISECONDS);
      return true;
    } else {
      return false;
    }
  } else {
    // So close to expiring any record of this nonce being used could have been cleared so
    // don't take a chance and just say no.
    return false;
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Open a bidirectional stream pipe.
 *
 * @param leftOpenListener the left-hand open listener
 * @param rightOpenListener the right-hand open listener
 * @param optionMap the pipe channel configuration
 * @throws java.io.IOException if the pipe could not be created
 * @deprecated Users should prefer the simpler {@link #createFullDuplexPipe()} instead.
 */
@Deprecated
public void createPipe(ChannelListener<? super StreamChannel> leftOpenListener, ChannelListener<? super StreamChannel> rightOpenListener, final OptionMap optionMap) throws IOException {
  final ChannelPipe<StreamChannel, StreamChannel> pipe = createFullDuplexPipe();
  final boolean establishWriting = optionMap.get(Options.WORKER_ESTABLISH_WRITING, false);
  final StreamChannel left = pipe.getLeftSide();
  XnioExecutor leftExec = establishWriting ? left.getWriteThread() : left.getReadThread();
  final StreamChannel right = pipe.getRightSide();
  XnioExecutor rightExec = establishWriting ? right.getWriteThread() : right.getReadThread();
  // not unsafe - http://youtrack.jetbrains.net/issue/IDEA-59290
  //noinspection unchecked
  leftExec.execute(ChannelListeners.getChannelListenerTask(left, leftOpenListener));
  // not unsafe - http://youtrack.jetbrains.net/issue/IDEA-59290
  //noinspection unchecked
  rightExec.execute(ChannelListeners.getChannelListenerTask(right, rightOpenListener));
}

代码示例来源:origin: org.mobicents.servlet.sip.containers/sip-servlets-as10

synchronized void bumpTimeout() {
  if(invalidationStarted) {
    return;
  }
  final int maxInactiveInterval = getMaxInactiveInterval();
  if (maxInactiveInterval > 0) {
    long newExpireTime = System.currentTimeMillis() + (maxInactiveInterval * 1000L);
    if(timerCancelKey != null && (newExpireTime < expireTime)) {
      // We have to re-schedule as the new maxInactiveInterval is lower than the old one
      if (!timerCancelKey.remove()) {
        return;
      }
      timerCancelKey = null;
    }
    expireTime = newExpireTime;
    if(timerCancelKey == null) {
      //+1 second, to make sure that the time has actually expired
      //we don't re-schedule every time, as it is expensive
      //instead when it expires we check if the timeout has been bumped, and if so we re-schedule
      timerCancelKey = executor.executeAfter(cancelTask, (maxInactiveInterval * 1000L) + 1, TimeUnit.MILLISECONDS);
    }
  }
  if (evictionToken != null) {
    Object token = evictionToken;
    if (evictionTokenUpdater.compareAndSet(this, token, null)) {
      sessionManager.evictionQueue.removeToken(token);
      this.evictionToken = sessionManager.evictionQueue.offerLastAndReturnToken(sessionId);
    }
  }
}

代码示例来源:origin: org.mobicents.servlet.sip.containers/sip-servlets-as8

synchronized void bumpTimeout() {
  if(invalidationStarted) {
    return;
  }
  final int maxInactiveInterval = getMaxInactiveInterval();
  if (maxInactiveInterval > 0) {
    long newExpireTime = System.currentTimeMillis() + (maxInactiveInterval * 1000L);
    if(timerCancelKey != null && (newExpireTime < expireTime)) {
      // We have to re-schedule as the new maxInactiveInterval is lower than the old one
      if (!timerCancelKey.remove()) {
        return;
      }
      timerCancelKey = null;
    }
    expireTime = newExpireTime;
    if(timerCancelKey == null) {
      //+1 second, to make sure that the time has actually expired
      //we don't re-schedule every time, as it is expensive
      //instead when it expires we check if the timeout has been bumped, and if so we re-schedule
      timerCancelKey = executor.executeAfter(cancelTask, (maxInactiveInterval * 1000L) + 1, TimeUnit.MILLISECONDS);
    }
  }
  if (evictionToken != null) {
    Object token = evictionToken;
    if (evictionTokenUpdater.compareAndSet(this, token, null)) {
      sessionManager.evictionQueue.removeToken(token);
      this.evictionToken = sessionManager.evictionQueue.offerLastAndReturnToken(sessionId);
    }
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

} else {
  if (heartbeatInterval != Integer.MAX_VALUE) {
    this.heartKey = channel.getWriteThread().executeAfter(heartbeatCommand, heartbeatInterval, TimeUnit.MILLISECONDS);

代码示例来源:origin: org.jboss.remoting3/jboss-remoting

this.heartKey = channel.getWriteThread().executeAfter(heartbeatCommand, heartbeatInterval, TimeUnit.MILLISECONDS);

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com