All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.linkedin.parseq.DelayedExecutorAdapter Maven / Gradle / Ivy

package com.linkedin.parseq;

import com.linkedin.parseq.DelayedExecutor;
import com.linkedin.parseq.internal.CancellableScheduledFuture;
import com.linkedin.parseq.Cancellable;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;


/**
 * Adapts a {@link ScheduledExecutorService} to the simpler
 * {@link DelayedExecutor} interface.
 *
 * @author Chris Pettitt
 */
public class DelayedExecutorAdapter implements DelayedExecutor {
  private final ScheduledExecutorService _scheduler;

  public DelayedExecutorAdapter(final ScheduledExecutorService scheduler) {
    _scheduler = scheduler;
  }

  @Override
  public Cancellable schedule(final long delay, final TimeUnit unit, final Runnable command) {
    return new CancellableScheduledFuture(_scheduler.schedule(command, delay, unit));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy