Package com.linkedin.parseq

Source Code of com.linkedin.parseq.DelayedExecutorAdapter

package com.linkedin.parseq;

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

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));
  }
}
TOP

Related Classes of com.linkedin.parseq.DelayedExecutorAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.