-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always provide executor to CompletableFuture::*Async (#1243)
- Loading branch information
Showing
11 changed files
with
100 additions
and
70 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
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
24 changes: 24 additions & 0 deletions
24
ingestion-sink/src/main/java/com/mozilla/telemetry/ingestion/sink/util/TimedFuture.java
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,24 @@ | ||
package com.mozilla.telemetry.ingestion.sink.util; | ||
|
||
import java.time.Duration; | ||
import java.util.Timer; | ||
import java.util.TimerTask; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* A non-blocking Future that will complete after some amount of time has passed. | ||
*/ | ||
public class TimedFuture extends CompletableFuture<Void> { | ||
|
||
public TimedFuture(Duration delay) { | ||
new Timer().schedule(new CompleteTask(), delay.toMillis()); | ||
} | ||
|
||
private class CompleteTask extends TimerTask { | ||
|
||
@Override | ||
public void run() { | ||
complete(null); | ||
} | ||
} | ||
} |
Oops, something went wrong.