java.util.concurrent.ScheduledThreadPoolExecutor.decorateTask()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(92)

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

ScheduledThreadPoolExecutor.decorateTask介绍

[英]Modifies or replaces the task used to execute a runnable. This method can be used to override the concrete class used for managing internal tasks. The default implementation simply returns the given task.
[中]修改或替换用于执行可运行任务的任务。此方法可用于重写用于管理内部任务的具体类。默认实现只返回给定的任务。

代码示例

代码示例来源:origin: kaaproject/kaa

@Override
 protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable,
                            RunnableScheduledFuture<V> task) {
  if (runnable instanceof CancelableRunnable) {
   return new CancelableScheduledFuture<V>((CancelableRunnable) runnable, task);
  }
  return super.decorateTask(runnable, task);
 }
};

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public ScheduledFuture<?> schedule(Runnable command,
                  long delay,
                  TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<?> t = decorateTask(command,
    new ScheduledFutureTask<Void>(command, null,
                   triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                    long delay,
                    TimeUnit unit) {
  if (callable == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<V> t = decorateTask(callable,
    new ScheduledFutureTask<V>(callable,
                  triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 * @throws IllegalArgumentException   {@inheritDoc}
 */
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
                       long initialDelay,
                       long period,
                       TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  if (period <= 0)
    throw new IllegalArgumentException();
  ScheduledFutureTask<Void> sft =
    new ScheduledFutureTask<Void>(command,
                   null,
                   triggerTime(initialDelay, unit),
                   unit.toNanos(period));
  RunnableScheduledFuture<Void> t = decorateTask(command, sft);
  sft.outerTask = t;
  delayedExecute(t);
  return t;
}

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

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 * @throws IllegalArgumentException   {@inheritDoc}
 */
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
                         long initialDelay,
                         long delay,
                         TimeUnit unit) {
  if (command == null || unit == null)
    throw new NullPointerException();
  if (delay <= 0)
    throw new IllegalArgumentException();
  ScheduledFutureTask<Void> sft =
    new ScheduledFutureTask<Void>(command,
                   null,
                   triggerTime(initialDelay, unit),
                   unit.toNanos(-delay));
  RunnableScheduledFuture<Void> t = decorateTask(command, sft);
  sft.outerTask = t;
  delayedExecute(t);
  return t;
}

代码示例来源:origin: mulesoft/mule

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable, RunnableScheduledFuture<V> task) {
 scheduledTasks.incrementAndGet();
 return super.decorateTask(runnable, task);
}

代码示例来源:origin: mulesoft/mule

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Callable<V> callable, RunnableScheduledFuture<V> task) {
 scheduledTasks.incrementAndGet();
 return super.decorateTask(callable, task);
}

代码示例来源:origin: org.mule.tests/mule-tests-unit

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Callable<V> callable, RunnableScheduledFuture<V> task) {
 scheduledTasks.incrementAndGet();
 return super.decorateTask(callable, task);
}

代码示例来源:origin: org.mule.tests/mule-tests-unit

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable, RunnableScheduledFuture<V> task) {
 scheduledTasks.incrementAndGet();
 return super.decorateTask(runnable, task);
}

代码示例来源:origin: org.terracotta/terracotta-l1

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(final Runnable runnable,
                           final RunnableScheduledFuture<V> task) {
 if (runnable instanceof TimerNamedRunnable) {
  final TimerNamedRunnable namedRunnable = (TimerNamedRunnable)runnable;
  return new NamedRunnableScheduledFuture<V>(namedRunnable, task);
 } else {
  return super.decorateTask(runnable, task);
 }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable, RunnableScheduledFuture<V> task) {
  if (!manualRemoveOnCancel) {
    return super.decorateTask(runnable, task);
  }
  return new RemoveOnCancelFuture<V>(runnable, task, this);
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Callable<V> callable, RunnableScheduledFuture<V> task) {
  if (!manualRemoveOnCancel) {
    return super.decorateTask(callable, task);
  }
  return new RemoveOnCancelFuture<V>(callable, task, this);
}

代码示例来源:origin: org.terracotta/terracotta-ee

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(final Runnable runnable,
                           final RunnableScheduledFuture<V> task) {
 if (runnable instanceof TimerNamedRunnable) {
  final TimerNamedRunnable namedRunnable = (TimerNamedRunnable)runnable;
  return new NamedRunnableScheduledFuture<V>(namedRunnable, task);
 } else {
  return super.decorateTask(runnable, task);
 }
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable, RunnableScheduledFuture<V> task) {
  if (!manualRemoveOnCancel) {
    return super.decorateTask(runnable, task);
  }
  return new RemoveOnCancelFuture<V>(runnable, task, this);
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Callable<V> callable, RunnableScheduledFuture<V> task) {
  if (!manualRemoveOnCancel) {
    return super.decorateTask(callable, task);
  }
  return new RemoveOnCancelFuture<V>(callable, task, this);
}

代码示例来源:origin: NationalSecurityAgency/emissary

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable, RunnableScheduledFuture<V> task) {
  if (runnable instanceof Roller) {
    return new RollFuture<>(task, (Roller) runnable);
  } else {
    return super.decorateTask(runnable, task);
  }
}

代码示例来源:origin: org.terracotta/terracotta-l1-ee

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(final Runnable runnable,
                           final RunnableScheduledFuture<V> task) {
 if (runnable instanceof TimerNamedRunnable) {
  final TimerNamedRunnable namedRunnable = (TimerNamedRunnable)runnable;
  return new NamedRunnableScheduledFuture<V>(namedRunnable, task);
 } else {
  return super.decorateTask(runnable, task);
 }
}

代码示例来源:origin: org.jbpm/jbpm-executor

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable, RunnableScheduledFuture<V> task) {
  RunnableScheduledFuture<V> r = super.decorateTask(runnable, task);
  
  if (runnable instanceof PrioritisedRunnable) {
    r = new PrioritisedScheduledFutureTask<V>(r, 
        ((PrioritisedRunnable) runnable).getPriority(), 
        ((PrioritisedRunnable) runnable).getFireDate());
    this.scheduled.putIfAbsent(((PrioritisedRunnable) runnable).getId(), r);
    logger.debug("Request job {} has been scheduled number of jobs in the pool {}", ((PrioritisedRunnable) runnable).getId(), scheduled.size());
  }
  
  return r;
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                    long delay,
                    TimeUnit unit) {
  if (callable == null || unit == null)
    throw new NullPointerException();
  RunnableScheduledFuture<V> t = decorateTask(callable,
    new ScheduledFutureTask<V>(callable,
                  triggerTime(delay, unit)));
  delayedExecute(t);
  return t;
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Callable<V> callable,
                           RunnableScheduledFuture<V> task) {
  if (callable instanceof AtomicCounterEditor.ConsolidatorTask) {
    total.incrementAndGet();
    return new CustomTask<V>(callable, task);
  } else {
    return super.decorateTask(callable, task);
  }
}

相关文章

微信公众号

最新文章

更多

ScheduledThreadPoolExecutor类方法