generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load glyphs in a separate thread with ThreadPoolExecutor
- Loading branch information
Showing
2 changed files
with
36 additions
and
3 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
21 changes: 21 additions & 0 deletions
21
src/client/java/net/vinrobot/mcemote/client/helpers/FutureHelper.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,21 @@ | ||
package net.vinrobot.mcemote.client.helpers; | ||
|
||
import java.util.Optional; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.Future; | ||
|
||
public final class FutureHelper { | ||
public static <T> Optional<T> asOptional(Future<T> future) { | ||
if (!future.isDone()) { | ||
return Optional.empty(); | ||
} | ||
|
||
try { | ||
return Optional.of(future.get()); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} catch (ExecutionException e) { | ||
throw new RuntimeException(e.getCause()); | ||
} | ||
} | ||
} |