Search in sources :

Example 1 with CURunnable

use of org.apache.openejb.threads.task.CURunnable in project tomee by apache.

the class ManagedExecutorServiceImpl method submit.

@Override
public <T> Future<T> submit(final Runnable task, final T result) {
    final CURunnable wrapper = new CURunnable(task);
    final Future<T> future = delegate.submit(wrapper, result);
    wrapper.taskSubmitted(future, this, task);
    return new CUFuture<>(future, wrapper);
}
Also used : CURunnable(org.apache.openejb.threads.task.CURunnable) CUFuture(org.apache.openejb.threads.future.CUFuture)

Example 2 with CURunnable

use of org.apache.openejb.threads.task.CURunnable in project tomee by apache.

the class ManagedScheduledExecutorServiceImpl method schedule.

@Override
public ScheduledFuture<?> schedule(final Runnable runnable, final Trigger trigger) {
    final Date taskScheduledTime = new Date();
    final AtomicReference<Future<?>> futureHandle = new AtomicReference<Future<?>>();
    final TriggerRunnable wrapper = new TriggerRunnable(this, runnable, new CURunnable(runnable), trigger, taskScheduledTime, getTaskId(runnable), AtomicReference.class.cast(futureHandle));
    final ScheduledFuture<?> future = delegate.schedule(wrapper, trigger.getNextRunTime(wrapper.getLastExecution(), taskScheduledTime).getTime() - nowMs(), TimeUnit.MILLISECONDS);
    return initTriggerScheduledFuture(runnable, AtomicReference.class.cast(futureHandle), wrapper, ScheduledFuture.class.cast(future));
}
Also used : CURunnable(org.apache.openejb.threads.task.CURunnable) CUScheduleFuture(org.apache.openejb.threads.future.CUScheduleFuture) ScheduledFuture(java.util.concurrent.ScheduledFuture) Future(java.util.concurrent.Future) AtomicReference(java.util.concurrent.atomic.AtomicReference) Date(java.util.Date) TriggerRunnable(org.apache.openejb.threads.task.TriggerRunnable) ScheduledFuture(java.util.concurrent.ScheduledFuture)

Example 3 with CURunnable

use of org.apache.openejb.threads.task.CURunnable in project tomee by apache.

the class ManagedScheduledExecutorServiceImpl method schedule.

@Override
public ScheduledFuture<?> schedule(final Runnable command, final long delay, final TimeUnit unit) {
    final CURunnable wrapper = new CURunnable(command);
    final ScheduledFuture<?> future = delegate.schedule(wrapper, delay, unit);
    wrapper.taskSubmitted(future, this, command);
    return new CUScheduleFuture<Object>(ScheduledFuture.class.cast(future), wrapper);
}
Also used : CURunnable(org.apache.openejb.threads.task.CURunnable) CUScheduleFuture(org.apache.openejb.threads.future.CUScheduleFuture) ScheduledFuture(java.util.concurrent.ScheduledFuture)

Example 4 with CURunnable

use of org.apache.openejb.threads.task.CURunnable in project tomee by apache.

the class ManagedScheduledExecutorServiceImpl method scheduleAtFixedRate.

@Override
public ScheduledFuture<?> scheduleAtFixedRate(final Runnable command, final long initialDelay, final long period, final TimeUnit unit) {
    final CURunnable wrapper = new CURunnable(command);
    final ScheduledFuture<?> future = delegate.scheduleAtFixedRate(wrapper, initialDelay, period, unit);
    wrapper.taskSubmitted(future, this, command);
    return new CUScheduleFuture<Object>(ScheduledFuture.class.cast(future), wrapper);
}
Also used : CURunnable(org.apache.openejb.threads.task.CURunnable) CUScheduleFuture(org.apache.openejb.threads.future.CUScheduleFuture) ScheduledFuture(java.util.concurrent.ScheduledFuture)

Example 5 with CURunnable

use of org.apache.openejb.threads.task.CURunnable in project tomee by apache.

the class ManagedExecutorServiceImpl method submit.

@Override
public Future<?> submit(final Runnable task) {
    final CURunnable wrapper = new CURunnable(task);
    final Future<?> future = delegate.submit(wrapper);
    wrapper.taskSubmitted(future, this, task);
    return new CUFuture<>(Future.class.cast(future), wrapper);
}
Also used : CURunnable(org.apache.openejb.threads.task.CURunnable) Future(java.util.concurrent.Future) CUFuture(org.apache.openejb.threads.future.CUFuture) CUFuture(org.apache.openejb.threads.future.CUFuture)

Aggregations

CURunnable (org.apache.openejb.threads.task.CURunnable)7 ScheduledFuture (java.util.concurrent.ScheduledFuture)4 CUScheduleFuture (org.apache.openejb.threads.future.CUScheduleFuture)4 Future (java.util.concurrent.Future)2 CUFuture (org.apache.openejb.threads.future.CUFuture)2 Date (java.util.Date)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 TriggerRunnable (org.apache.openejb.threads.task.TriggerRunnable)1