File tree Expand file tree Collapse file tree 5 files changed +24
-13
lines changed
src/main/java/com/falsepattern/lib Expand file tree Collapse file tree 5 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -52,14 +52,6 @@ public class FalsePatternLib {
5252 @ Getter private static final boolean developerEnvironment =
5353 (boolean ) Launch .blackboard .get ("fml.deobfuscatedEnvironment" );
5454
55- @ Getter
56- private static final ExecutorService asyncWorker = Executors .newSingleThreadExecutor ((runnable ) -> {
57- Thread thread = new Thread (runnable );
58- thread .setDaemon (true );
59- thread .setName (Tags .MODNAME + " Async Worker" );
60- return thread ;
61- });
62-
6355 @ SidedProxy (clientSide = Tags .GROUPNAME + ".internal.proxy.ClientProxy" , serverSide = Tags .GROUPNAME + ".internal.proxy.CommonProxy" )
6456 private static CommonProxy proxy ;
6557
Original file line number Diff line number Diff line change 22
33import com .falsepattern .lib .internal .FalsePatternLib ;
44import com .falsepattern .lib .text .FormattedText ;
5+ import com .falsepattern .lib .util .Async ;
56import cpw .mods .fml .common .Loader ;
67import cpw .mods .fml .common .event .FMLPostInitializationEvent ;
78import cpw .mods .fml .common .event .FMLPreInitializationEvent ;
@@ -33,7 +34,7 @@ public void preInit(FMLPreInitializationEvent e) {
3334 @ Override
3435 public void postInit (FMLPostInitializationEvent e ) {
3536 super .postInit (e );
36- chatFuture = FalsePatternLib . getAsyncWorker () .submit (() -> {
37+ chatFuture = Async . asyncWorker .submit (() -> {
3738 long start = System .nanoTime ();
3839 val updates = updatesFuture .get ();
3940 if (updates == null || updates .size () == 0 ) return null ;
Original file line number Diff line number Diff line change 77import com .falsepattern .lib .internal .Tags ;
88import com .falsepattern .lib .updates .ModUpdateInfo ;
99import com .falsepattern .lib .updates .UpdateChecker ;
10+ import com .falsepattern .lib .util .Async ;
1011import cpw .mods .fml .common .event .FMLConstructionEvent ;
1112import cpw .mods .fml .common .event .FMLPostInitializationEvent ;
1213import cpw .mods .fml .common .event .FMLPreInitializationEvent ;
@@ -35,7 +36,7 @@ public void preInit(FMLPreInitializationEvent e) {
3536 if (LibraryConfig .ENABLE_UPDATE_CHECKER ) {
3637 FalsePatternLib .getLog ().info ("Launching asynchronous update check." );
3738 val updateCheckFuture = UpdateChecker .fetchUpdatesAsync ("https://falsepattern.com/mc/versions.json" );
38- updatesFuture = FalsePatternLib . getAsyncWorker () .submit (() -> {
39+ updatesFuture = Async . asyncWorker .submit (() -> {
3940 if (!updateCheckFuture .isCancelled ()) {
4041 try {
4142 var updates = updateCheckFuture .get ();
Original file line number Diff line number Diff line change 88import com .falsepattern .lib .internal .Internet ;
99import com .falsepattern .lib .internal .LibraryConfig ;
1010import com .falsepattern .lib .internal .Tags ;
11+ import com .falsepattern .lib .util .Async ;
1112import cpw .mods .fml .common .Loader ;
1213import lombok .val ;
1314
1819import java .util .ArrayList ;
1920import java .util .Collections ;
2021import java .util .List ;
21- import java .util .concurrent .ExecutorService ;
22- import java .util .concurrent .Executors ;
2322import java .util .concurrent .Future ;
2423import java .util .concurrent .atomic .AtomicInteger ;
2524import java .util .concurrent .atomic .AtomicReference ;
@@ -34,7 +33,7 @@ public class UpdateChecker {
3433 * @return A future that will contain the update info about mods that were both available on the URL and installed
3534 */
3635 public static Future <List <ModUpdateInfo >> fetchUpdatesAsync (String url ) {
37- return FalsePatternLib . getAsyncWorker () .submit (() -> fetchUpdates (url ));
36+ return Async . asyncWorker .submit (() -> fetchUpdates (url ));
3837 }
3938
4039 /**
Original file line number Diff line number Diff line change 1+ package com .falsepattern .lib .util ;
2+
3+ import com .falsepattern .lib .StableAPI ;
4+ import com .falsepattern .lib .internal .Tags ;
5+ import lombok .Getter ;
6+
7+ import java .util .concurrent .ExecutorService ;
8+ import java .util .concurrent .Executors ;
9+
10+ @ StableAPI (since = "0.8.0" )
11+ public class Async {
12+ public static final ExecutorService asyncWorker = Executors .newSingleThreadExecutor ((runnable ) -> {
13+ Thread thread = new Thread (runnable );
14+ thread .setDaemon (true );
15+ thread .setName (Tags .MODNAME + " Async Worker" );
16+ return thread ;
17+ });
18+ }
You can’t perform that action at this time.
0 commit comments