类io.grpc.internal.LogExceptionRunnable源码实例Demo

下面列出了怎么用io.grpc.internal.LogExceptionRunnable的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: grpc-nebula-java   文件: TestServiceImpl.java
/**
 * Schedules the next response chunk to be dispatched. If all input has been received and there
 * are no more chunks in the queue, the stream is closed.
 */
private void scheduleNextChunk() {
  synchronized (this) {
    if (scheduled) {
      // Dispatch task is already scheduled.
      return;
    }

    // Schedule the next response chunk if there is one.
    Chunk nextChunk = chunks.peek();
    if (nextChunk != null) {
      scheduled = true;
      // TODO(ejona): cancel future if RPC is cancelled
      Future<?> unused = executor.schedule(new LogExceptionRunnable(dispatchTask),
          nextChunk.delayMicroseconds, TimeUnit.MICROSECONDS);
      return;
    }
  }
}
 
@VisibleForTesting
void start(final ChannelHandlerContext ctx, final ScheduledExecutorService scheduler) {
  this.scheduler = scheduler;
  nextIdleMonitorTime = ticker.nanoTime() + maxConnectionIdleInNanos;

  shutdownTask = new LogExceptionRunnable(new Runnable() {
    @Override
    public void run() {
      if (shutdownDelayed) {
        if (!isActive) {
          // delay shutdown
          shutdownFuture = scheduler.schedule(
              shutdownTask, nextIdleMonitorTime - ticker.nanoTime(), TimeUnit.NANOSECONDS);
          shutdownDelayed = false;
        }
        // if isActive, exit. Will schedule a new shutdownFuture once onTransportIdle
      } else {
        close(ctx);
        shutdownFuture = null;
      }
    }
  });

  shutdownFuture =
      scheduler.schedule(shutdownTask, maxConnectionIdleInNanos, TimeUnit.NANOSECONDS);
}
 
源代码3 项目: armeria   文件: TestServiceImpl.java
/**
 * Schedules the next response chunk to be dispatched. If all input has been received and there
 * are no more chunks in the queue, the stream is closed.
 */
private void scheduleNextChunk() {
    synchronized (this) {
        if (scheduled) {
            // Dispatch task is already scheduled.
            return;
        }

        // Schedule the next response chunk if there is one.
        final Chunk nextChunk = chunks.peek();
        if (nextChunk != null) {
            scheduled = true;
            // TODO(ejona): cancel future if RPC is cancelled
            final Future<?> unused = executor.schedule(new LogExceptionRunnable(dispatchTask),
                                                       nextChunk.delayMicroseconds,
                                                       TimeUnit.MICROSECONDS);
            return;
        }
    }
}
 
源代码4 项目: grpc-java   文件: TestServiceImpl.java
/**
 * Schedules the next response chunk to be dispatched. If all input has been received and there
 * are no more chunks in the queue, the stream is closed.
 */
private void scheduleNextChunk() {
  synchronized (this) {
    if (scheduled) {
      // Dispatch task is already scheduled.
      return;
    }

    // Schedule the next response chunk if there is one.
    Chunk nextChunk = chunks.peek();
    if (nextChunk != null) {
      scheduled = true;
      // TODO(ejona): cancel future if RPC is cancelled
      Future<?> unused = executor.schedule(new LogExceptionRunnable(dispatchTask),
          nextChunk.delayMicroseconds, TimeUnit.MICROSECONDS);
      return;
    }
  }
}
 
源代码5 项目: grpc-java   文件: MaxConnectionIdleManager.java
@VisibleForTesting
void start(final ChannelHandlerContext ctx, final ScheduledExecutorService scheduler) {
  this.scheduler = scheduler;
  nextIdleMonitorTime = ticker.nanoTime() + maxConnectionIdleInNanos;

  shutdownTask = new LogExceptionRunnable(new Runnable() {
    @Override
    public void run() {
      if (shutdownDelayed) {
        if (!isActive) {
          // delay shutdown
          shutdownFuture = scheduler.schedule(
              shutdownTask, nextIdleMonitorTime - ticker.nanoTime(), TimeUnit.NANOSECONDS);
          shutdownDelayed = false;
        }
        // if isActive, exit. Will schedule a new shutdownFuture once onTransportIdle
      } else {
        close(ctx);
        shutdownFuture = null;
      }
    }
  });

  shutdownFuture =
      scheduler.schedule(shutdownTask, maxConnectionIdleInNanos, TimeUnit.NANOSECONDS);
}
 
 类所在包
 类方法
 同包方法