Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
216 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package net.jodah.recurrent; | ||
|
||
import java.util.concurrent.Callable; | ||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Schedules invocations. | ||
* | ||
* @author Jonathan Halterman | ||
*/ | ||
public interface Scheduler { | ||
/** | ||
* Schedules the {@code callable} to be called after the {@code delay} for the {@code unit}. | ||
*/ | ||
ScheduledFuture<?> schedule(Callable<?> callable, long delay, TimeUnit unit); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package net.jodah.recurrent; | ||
|
||
import java.util.concurrent.Callable; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* {@link Scheduler} utilities. | ||
* | ||
* @author Jonathan Halterman | ||
*/ | ||
public final class Schedulers { | ||
private Schedulers() { | ||
} | ||
|
||
public static Scheduler of(final ScheduledExecutorService executor) { | ||
return new Scheduler() { | ||
@Override | ||
public ScheduledFuture<?> schedule(Callable<?> callable, long delay, TimeUnit unit) { | ||
return executor.schedule(callable, delay, unit); | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.