类java.util.concurrent.RunnableScheduledFuture源码实例Demo

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

/**
 * @see {@link java.util.concurrent.ScheduledThreadPoolExecutor.ScheduledFutureTask}
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable, RunnableScheduledFuture<V> task) {
	if (runnable instanceof RandomScheduleRunnable) {
		try {
			return new CustomScheduledFutureTask<V>((Callable) callableField.get(task), (long) timeField.get(task), this) {
				@Override
				public long getPeriod() {
					return ((RandomScheduleRunnable) runnable).nextDelay();
				}
			};
		} catch (Exception e) {
			throw new IllegalStateException(e);
		}
	}
	return task;
}
 
源代码2 项目: openjdk-jdk9   文件: ScheduledTickleService.java
public static void realMain(String... args) throws InterruptedException {
    // our tickle service
    ScheduledExecutorService tickleService =
        new ScheduledThreadPoolExecutor(concurrency) {
            // We override decorateTask() to return a custom
            // RunnableScheduledFuture which explicitly removes
            // itself from the queue after cancellation.
            protected <V> RunnableScheduledFuture<V>
                decorateTask(Runnable runnable,
                             RunnableScheduledFuture<V> task) {
                final ScheduledThreadPoolExecutor exec = this;
                return new CustomRunnableScheduledFuture<V>(task) {
                    // delegate to wrapped task, except for:
                    public boolean cancel(boolean b) {
                        // cancel wrapped task & remove myself from the queue
                        return (task().cancel(b)
                                && exec.remove(this));}};}};

    for (int i = 0; i < concurrency; i++)
        new ScheduledTickle(i, tickleService)
            .setUpdateInterval(25, MILLISECONDS);

    done.await();
    tickleService.shutdown();
    pass();
}
 
源代码3 项目: quarks   文件: TrackingScheduledExecutor.java
/**
 * Determines whether there are tasks which have started and not completed.
 * 
 * As a side effect, this method removes all tasks which are done but are
 * still in the tracking list.
 * 
 * @return {@code true} is active tasks exist.
 */
public boolean hasActiveTasks() {
    boolean doesHaveTasks = false; 
    synchronized (asyncTasks) {
        if (asyncTasks.isEmpty())
            return false;
        
        Iterator<RunnableScheduledFuture<?>> i = asyncTasks.iterator();
        while (i.hasNext()) {
            RunnableScheduledFuture<?> task = i.next();
            if (task.isDone())
                 i.remove();
            else
                doesHaveTasks = true;
        }
    }
    return doesHaveTasks;
}
 
protected <V> RunnableScheduledFuture<V> queue(final RunnableScheduledFuture<V> future) {
	if (isShutdown()) {
		throw new RejectedExecutionException();
	}
	if (getPoolSize() < getCorePoolSize()) {
		prestartCoreThread();
	}

	if (future instanceof DominoFutureTask) {
		DominoFutureTask<?> dft = (DominoFutureTask<?>) future;
		tasks.put(dft.sequenceNumber, dft);
		if (dft.getDelay(TimeUnit.NANOSECONDS) > 0) {
			dft.setState(TaskState.SLEEPING);
		}
	}
	super.getQueue().add(future);
	return future;
}
 
private boolean isPeriodic(Future<?> future) {
  if (future instanceof RunnableScheduledFuture<?>) {
    RunnableScheduledFuture<?> runnableFuture = (RunnableScheduledFuture<?>) future;
    if (runnableFuture.isPeriodic()) {
      return true;
    }
  }
  return false;
}
 
源代码6 项目: emissary   文件: RollScheduledExecutor.java
@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);
    }
}
 
@Test
public void createDefaultPublishModel() throws JsonProcessingException {
  new Expectations() {
    {
      threadPoolExecutor.getQueue();
      result = queue;
      queue.size();
      result = 10d;
    }
  };
  new MockUp<ScheduledThreadPoolExecutor>() {
    @Mock
    void delayedExecute(RunnableScheduledFuture<?> task) {

    }
  };
  try {
    ThreadPoolMonitor.attach(registry, threadPoolExecutor, "test");

    PolledMeter.update(registry);
    PublishModelFactory factory = new PublishModelFactory(Lists.newArrayList(registry.iterator()));
    DefaultPublishModel model = factory.createDefaultPublishModel();

    Assert.assertEquals(
        "{\"test\":{\"avgTaskCount\":0.0,\"avgCompletedTaskCount\":0.0,\"currentThreadsBusy\":0,\"maxThreads\":0,\"poolSize\":0,\"corePoolSize\":0,\"queueSize\":10,\"rejected\":\"NaN\"}}",
        JsonUtils.writeValueAsString(model.getThreadPools()));
  } catch (Throwable e) {
    e.printStackTrace();
    Assert.fail("unexpected error happen. " + e.getMessage());
  }
}
 
源代码8 项目: bt   文件: NonblockingScheduledExecutor.java
void doStateMaintenance() {
	
	while(!isShutdown()) {
		RunnableScheduledFuture<?> toSchedule;
		while((toSchedule = submittedScheduledTasks.poll()) != null)
			delayedTasks.add(toSchedule);
		RunnableScheduledFuture<?> toExecute;
		while((toExecute = delayedTasks.peek()) != null && toExecute.getDelay(TimeUnit.NANOSECONDS) <= 0) {
			delayedTasks.poll();
			immediateExecutor.executeWithoutWakeup(toExecute);
		}
		
		RunnableScheduledFuture<?> nextTask = delayedTasks.peek();

		// signal current thread as suspended before we actually check work queues.
		// this avoids wakeupWaiter() seeing an inconsistent state
		currentSleeper.set(Thread.currentThread());

		if(executorQueue.isEmpty() && submittedScheduledTasks.isEmpty()) {
			if(nextTask != null)
				LockSupport.parkNanos(nextTask.getDelay(TimeUnit.NANOSECONDS));
			else
				LockSupport.park();
			currentSleeper.set(null);
		} else {
			currentSleeper.set(null);
			// there are unmatched tasks in the queue, return this thread to the pool
			break;
		}
	}
	
	
	// reschedule if we fall out of loop
	if(!isShutdown())
		immediateExecutor.executeWithoutWakeup(scheduler);
}
 
源代码9 项目: quarks   文件: TrackingScheduledExecutor.java
private int cancelAllAsyncTasks(boolean mayInterruptIfRunning) {
    int notCanceled = 0;
    synchronized (asyncTasks) {
        for (RunnableScheduledFuture<?> task : asyncTasks) {
            if (!task.cancel(mayInterruptIfRunning))
                notCanceled++;
        }
        // remove tasks which are done
        hasActiveTasks();
    }
    return notCanceled;
}
 
源代码10 项目: mldht   文件: NonblockingScheduledExecutor.java
void doStateMaintenance() {
	
	while(!isShutdown()) {
		RunnableScheduledFuture<?> toSchedule;
		while((toSchedule = submittedScheduledTasks.poll()) != null)
			delayedTasks.add(toSchedule);
		RunnableScheduledFuture<?> toExecute;
		while((toExecute = delayedTasks.peek()) != null && toExecute.getDelay(TimeUnit.NANOSECONDS) <= 0) {
			delayedTasks.poll();
			immediateExecutor.executeWithoutWakeup(toExecute);
		}
		
		RunnableScheduledFuture<?> nextTask = delayedTasks.peek();

		// signal current thread as suspended before we actually check work queues.
		// this avoids wakeupWaiter() seeing an inconsistent state
		currentSleeper.set(Thread.currentThread());

		if(executorQueue.isEmpty() && submittedScheduledTasks.isEmpty()) {
			if(nextTask != null)
				LockSupport.parkNanos(nextTask.getDelay(TimeUnit.NANOSECONDS));
			else
				LockSupport.park();
			currentSleeper.set(null);
		} else {
			currentSleeper.set(null);
			// there are unmatched tasks in the queue, return this thread to the pool
			break;
		}
	}
	
	
	// reschedule if we fall out of loop
	if(!isShutdown())
		immediateExecutor.executeWithoutWakeup(scheduler);
}
 
源代码11 项目: reactor-core   文件: SchedulersTest.java
boolean isAllTasksCancelled() {
	for(RunnableScheduledFuture<?> task: tasks) {
		if (!task.isCancelled()) {
			return false;
		}
	}
	return true;
}
 
源代码12 项目: reactor-core   文件: SchedulersTest.java
boolean isAllTasksCancelledOrDone() {
	for(RunnableScheduledFuture<?> task: tasks) {
		if (!task.isCancelled() && !task.isDone()) {
			return false;
		}
	}
	return true;
}
 
LazyTraceScheduledThreadPoolExecutor(int corePoolSize, BeanFactory beanFactory,
		ScheduledThreadPoolExecutor delegate) {
	super(corePoolSize);
	this.beanFactory = beanFactory;
	this.delegate = delegate;
	this.decorateTaskRunnable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "decorateTask", Runnable.class,
			RunnableScheduledFuture.class);
	makeAccessibleIfNotNull(this.decorateTaskRunnable);
	this.decorateTaskCallable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "decorateTaskCallable", Callable.class,
			RunnableScheduledFuture.class);
	makeAccessibleIfNotNull(this.decorateTaskCallable);
	this.finalize = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"finalize", null);
	makeAccessibleIfNotNull(this.finalize);
	this.beforeExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"beforeExecute", null);
	makeAccessibleIfNotNull(this.beforeExecute);
	this.afterExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"afterExecute", null);
	makeAccessibleIfNotNull(this.afterExecute);
	this.terminated = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"terminated", null);
	makeAccessibleIfNotNull(this.terminated);
	this.newTaskForRunnable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "newTaskFor", Runnable.class,
			Object.class);
	makeAccessibleIfNotNull(this.newTaskForRunnable);
	this.newTaskForCallable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "newTaskFor", Callable.class,
			Object.class);
	makeAccessibleIfNotNull(this.newTaskForCallable);
}
 
LazyTraceScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory,
		BeanFactory beanFactory, ScheduledThreadPoolExecutor delegate) {
	super(corePoolSize, threadFactory);
	this.beanFactory = beanFactory;
	this.delegate = delegate;
	this.decorateTaskRunnable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "decorateTask", Runnable.class,
			RunnableScheduledFuture.class);
	makeAccessibleIfNotNull(this.decorateTaskRunnable);
	this.decorateTaskCallable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "decorateTaskCallable", Callable.class,
			RunnableScheduledFuture.class);
	makeAccessibleIfNotNull(this.decorateTaskCallable);
	this.finalize = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"finalize");
	makeAccessibleIfNotNull(this.finalize);
	this.beforeExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"beforeExecute");
	makeAccessibleIfNotNull(this.beforeExecute);
	this.afterExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"afterExecute", null);
	makeAccessibleIfNotNull(this.afterExecute);
	this.terminated = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"terminated", null);
	makeAccessibleIfNotNull(this.terminated);
	this.newTaskForRunnable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "newTaskFor", Runnable.class,
			Object.class);
	makeAccessibleIfNotNull(this.newTaskForRunnable);
	this.newTaskForCallable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "newTaskFor", Callable.class,
			Object.class);
	makeAccessibleIfNotNull(this.newTaskForCallable);
}
 
LazyTraceScheduledThreadPoolExecutor(int corePoolSize,
		RejectedExecutionHandler handler, BeanFactory beanFactory,
		ScheduledThreadPoolExecutor delegate) {
	super(corePoolSize, handler);
	this.beanFactory = beanFactory;
	this.delegate = delegate;
	this.decorateTaskRunnable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "decorateTask", Runnable.class,
			RunnableScheduledFuture.class);
	makeAccessibleIfNotNull(this.decorateTaskRunnable);
	this.decorateTaskCallable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "decorateTaskCallable", Callable.class,
			RunnableScheduledFuture.class);
	makeAccessibleIfNotNull(this.decorateTaskCallable);
	this.finalize = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"finalize", null);
	makeAccessibleIfNotNull(this.finalize);
	this.beforeExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"beforeExecute", null);
	makeAccessibleIfNotNull(this.beforeExecute);
	this.afterExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"afterExecute", null);
	makeAccessibleIfNotNull(this.afterExecute);
	this.terminated = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"terminated", null);
	makeAccessibleIfNotNull(this.terminated);
	this.newTaskForRunnable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "newTaskFor", Runnable.class,
			Object.class);
	makeAccessibleIfNotNull(this.newTaskForRunnable);
	this.newTaskForCallable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "newTaskFor", Callable.class,
			Object.class);
	makeAccessibleIfNotNull(this.newTaskForCallable);
}
 
LazyTraceScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory,
		RejectedExecutionHandler handler, BeanFactory beanFactory,
		ScheduledThreadPoolExecutor delegate) {
	super(corePoolSize, threadFactory, handler);
	this.beanFactory = beanFactory;
	this.delegate = delegate;
	this.decorateTaskRunnable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "decorateTask", Runnable.class,
			RunnableScheduledFuture.class);
	makeAccessibleIfNotNull(this.decorateTaskRunnable);
	this.decorateTaskCallable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "decorateTaskCallable", Callable.class,
			RunnableScheduledFuture.class);
	makeAccessibleIfNotNull(this.decorateTaskCallable);
	this.finalize = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"finalize", null);
	makeAccessibleIfNotNull(this.finalize);
	this.beforeExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"beforeExecute", null);
	makeAccessibleIfNotNull(this.beforeExecute);
	this.afterExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"afterExecute", null);
	makeAccessibleIfNotNull(this.afterExecute);
	this.terminated = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
			"terminated");
	makeAccessibleIfNotNull(this.terminated);
	this.newTaskForRunnable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "newTaskFor", Runnable.class,
			Object.class);
	makeAccessibleIfNotNull(this.newTaskForRunnable);
	this.newTaskForCallable = ReflectionUtils.findMethod(
			ScheduledThreadPoolExecutor.class, "newTaskFor", Callable.class,
			Object.class);
	makeAccessibleIfNotNull(this.newTaskForCallable);
}
 
@Override
@SuppressWarnings("unchecked")
public <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable,
		RunnableScheduledFuture<V> task) {
	return (RunnableScheduledFuture<V>) ReflectionUtils.invokeMethod(
			this.decorateTaskRunnable, this.delegate,
			new TraceRunnable(tracing(), spanNamer(), runnable), task);
}
 
@Override
@SuppressWarnings("unchecked")
public <V> RunnableScheduledFuture<V> decorateTask(Callable<V> callable,
		RunnableScheduledFuture<V> task) {
	return (RunnableScheduledFuture<V>) ReflectionUtils.invokeMethod(
			this.decorateTaskCallable, this.delegate,
			new TraceCallable<>(tracing(), spanNamer(), callable), task);
}
 
public MetricsTask(RunnableScheduledFuture<V> delegate) {
  this.delegate = delegate;
  if(isPeriodic()) {
    ((AtomicInteger) gaugeMap.get(KEY_PERIODIC_COUNT)).incrementAndGet();
  } else {
    ((AtomicInteger) gaugeMap.get(KEY_WAITING_COUNT)).incrementAndGet();
  }
}
 
LazyTraceScheduledThreadPoolExecutor(int corePoolSize, ScheduledThreadPoolExecutor delegate) {
    super(corePoolSize);
    this.delegate = delegate;
    this.decorateTaskRunnable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "decorateTask", Runnable.class,
            RunnableScheduledFuture.class);
    makeAccessibleIfNotNull(this.decorateTaskRunnable);
    this.decorateTaskCallable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "decorateTaskCallable", Callable.class,
            RunnableScheduledFuture.class);
    makeAccessibleIfNotNull(this.decorateTaskCallable);
    this.finalize = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
            "finalize", null);
    makeAccessibleIfNotNull(this.finalize);
    this.beforeExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
            "beforeExecute", null);
    makeAccessibleIfNotNull(this.beforeExecute);
    this.afterExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
            "afterExecute", null);
    makeAccessibleIfNotNull(this.afterExecute);
    this.terminated = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
            "terminated", null);
    makeAccessibleIfNotNull(this.terminated);
    this.newTaskForRunnable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "newTaskFor", Runnable.class,
            Object.class);
    makeAccessibleIfNotNull(this.newTaskForRunnable);
    this.newTaskForCallable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "newTaskFor", Callable.class,
            Object.class);
    makeAccessibleIfNotNull(this.newTaskForCallable);
}
 
LazyTraceScheduledThreadPoolExecutor(
        int corePoolSize,
        ThreadFactory threadFactory,
        ScheduledThreadPoolExecutor delegate) {
    super(corePoolSize, threadFactory);
    this.delegate = delegate;
    this.decorateTaskRunnable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "decorateTask", Runnable.class,
            RunnableScheduledFuture.class);
    makeAccessibleIfNotNull(this.decorateTaskRunnable);
    this.decorateTaskCallable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "decorateTaskCallable", Callable.class,
            RunnableScheduledFuture.class);
    makeAccessibleIfNotNull(this.decorateTaskCallable);
    this.finalize = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class,
            "finalize");
    makeAccessibleIfNotNull(this.finalize);
    this.beforeExecute = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class,
            "beforeExecute");
    makeAccessibleIfNotNull(this.beforeExecute);
    this.afterExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
            "afterExecute", null);
    makeAccessibleIfNotNull(this.afterExecute);
    this.terminated = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
            "terminated", null);
    makeAccessibleIfNotNull(this.terminated);
    this.newTaskForRunnable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "newTaskFor", Runnable.class,
            Object.class);
    makeAccessibleIfNotNull(this.newTaskForRunnable);
    this.newTaskForCallable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "newTaskFor", Callable.class,
            Object.class);
    makeAccessibleIfNotNull(this.newTaskForCallable);
}
 
LazyTraceScheduledThreadPoolExecutor(
        int corePoolSize,
        RejectedExecutionHandler handler,
        ScheduledThreadPoolExecutor delegate) {
    super(corePoolSize, handler);
    this.delegate = delegate;
    this.decorateTaskRunnable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "decorateTask", Runnable.class,
            RunnableScheduledFuture.class);
    makeAccessibleIfNotNull(this.decorateTaskRunnable);
    this.decorateTaskCallable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "decorateTaskCallable", Callable.class,
            RunnableScheduledFuture.class);
    makeAccessibleIfNotNull(this.decorateTaskCallable);
    this.finalize = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
            "finalize", null);
    makeAccessibleIfNotNull(this.finalize);
    this.beforeExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
            "beforeExecute", null);
    makeAccessibleIfNotNull(this.beforeExecute);
    this.afterExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
            "afterExecute", null);
    makeAccessibleIfNotNull(this.afterExecute);
    this.terminated = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
            "terminated", null);
    makeAccessibleIfNotNull(this.terminated);
    this.newTaskForRunnable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "newTaskFor", Runnable.class,
            Object.class);
    makeAccessibleIfNotNull(this.newTaskForRunnable);
    this.newTaskForCallable = ReflectionUtils.findMethod(
            ScheduledThreadPoolExecutor.class, "newTaskFor", Callable.class,
            Object.class);
    makeAccessibleIfNotNull(this.newTaskForCallable);
}
 
LazyTraceScheduledThreadPoolExecutor(
         int corePoolSize,
ThreadFactory threadFactory,
         RejectedExecutionHandler handler,
         ScheduledThreadPoolExecutor delegate) {
     super(corePoolSize, threadFactory, handler);
     this.delegate = delegate;
     this.decorateTaskRunnable = ReflectionUtils.findMethod(
             ScheduledThreadPoolExecutor.class, "decorateTask", Runnable.class,
             RunnableScheduledFuture.class);
     makeAccessibleIfNotNull(this.decorateTaskRunnable);
     this.decorateTaskCallable = ReflectionUtils.findMethod(
             ScheduledThreadPoolExecutor.class, "decorateTaskCallable", Callable.class,
             RunnableScheduledFuture.class);
     makeAccessibleIfNotNull(this.decorateTaskCallable);
     this.finalize = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
             "finalize", null);
     makeAccessibleIfNotNull(this.finalize);
     this.beforeExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
             "beforeExecute", null);
     makeAccessibleIfNotNull(this.beforeExecute);
     this.afterExecute = ReflectionUtils.findMethod(ScheduledThreadPoolExecutor.class,
             "afterExecute", null);
     makeAccessibleIfNotNull(this.afterExecute);
     this.terminated = ReflectionUtils.findMethod(
             ScheduledThreadPoolExecutor.class,
             "terminated");
     makeAccessibleIfNotNull(this.terminated);
     this.newTaskForRunnable = ReflectionUtils.findMethod(
             ScheduledThreadPoolExecutor.class, "newTaskFor", Runnable.class,
             Object.class);
     makeAccessibleIfNotNull(this.newTaskForRunnable);
     this.newTaskForCallable = ReflectionUtils.findMethod(
             ScheduledThreadPoolExecutor.class, "newTaskFor", Callable.class,
             Object.class);
     makeAccessibleIfNotNull(this.newTaskForCallable);
 }
 
@Override
  @SuppressWarnings("unchecked")
  public <V> RunnableScheduledFuture<V> decorateTask(
          Runnable runnable,
          RunnableScheduledFuture<V> task) {
return (RunnableScheduledFuture<V>) ReflectionUtils.invokeMethod(
		this.decorateTaskRunnable,
		this.delegate,
		TraceRunnable.wrap(runnable),
		task);
  }
 
@Override
  @SuppressWarnings("unchecked")
  public <V> RunnableScheduledFuture<V> decorateTask(
          Callable<V> callable,
          RunnableScheduledFuture<V> task) {
return (RunnableScheduledFuture<V>) ReflectionUtils.invokeMethod(
		this.decorateTaskCallable,
		this.delegate,
		TraceCallable.wrap(callable),
		task);
  }
 
@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Runnable runnable, RunnableScheduledFuture<V> task) {
    return runnable instanceof NonNotifyRunnable ?
            task : new RunnableScheduledFutureTask<V>(this, runnable, task);
}
 
@Override
protected <V> RunnableScheduledFuture<V> decorateTask(Callable<V> callable, RunnableScheduledFuture<V> task) {
    return new RunnableScheduledFutureTask<V>(this, callable, task);
}
 
RunnableScheduledFutureTask(EventExecutor executor, Runnable runnable,
                                   RunnableScheduledFuture<V> future) {
    super(executor, runnable, null);
    this.future = future;
}
 
RunnableScheduledFutureTask(EventExecutor executor, Callable<V> callable,
                                   RunnableScheduledFuture<V> future) {
    super(executor, callable);
    this.future = future;
}
 
源代码30 项目: emissary   文件: RollScheduledExecutor.java
public RollFuture(RunnableScheduledFuture<V> rsf, Roller r) {
    this.rsf = rsf;
    this.r = r;
}
 
 类所在包
 类方法
 同包方法