gpt4 book ai didi

org.xnio.XnioExecutor.executeAfter()方法的使用及代码示例

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

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

XnioExecutor.executeAfter介绍

[英]Execute a command after a period of time. At least the amount of time given in time will have elapsed when the task is run. The returned key may be used to cancel the task before it runs.
[中]在一段时间后执行命令。任务运行时,至少会经过给定的时间量。返回的密钥可用于在任务运行前取消任务。

代码示例

代码示例来源: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

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

代码示例来源: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

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.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);

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