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

com.fitbur.failsafe.util.concurrent.Schedulers Maven / Gradle / Ivy

The newest version!
package com.fitbur.failsafe.util.concurrent;

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

import com.fitbur.failsafe.internal.util.Assert;

/**
 * {@link Scheduler} utilities.
 * 
 * @author Jonathan Halterman
 * @see com.fitbur.failsafe.util.concurrent.DefaultScheduledFuture
 */
public final class Schedulers {
  private Schedulers() {
  }

  /**
   * Returns a Scheduler adapted from the {@code executor}.
   * 
   * @throws NullPointerException if {@code executor} is null
   */
  public static Scheduler of(final ScheduledExecutorService executor) {
    Assert.notNull(executor, "executor");
    return new Scheduler() {
      @Override
      public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) {
        return executor.schedule(callable, delay, unit);
      }
    };
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy