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 {
52
52
@ Getter private static final boolean developerEnvironment =
53
53
(boolean ) Launch .blackboard .get ("fml.deobfuscatedEnvironment" );
54
54
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
-
63
55
@ SidedProxy (clientSide = Tags .GROUPNAME + ".internal.proxy.ClientProxy" , serverSide = Tags .GROUPNAME + ".internal.proxy.CommonProxy" )
64
56
private static CommonProxy proxy ;
65
57
Original file line number Diff line number Diff line change 2
2
3
3
import com .falsepattern .lib .internal .FalsePatternLib ;
4
4
import com .falsepattern .lib .text .FormattedText ;
5
+ import com .falsepattern .lib .util .Async ;
5
6
import cpw .mods .fml .common .Loader ;
6
7
import cpw .mods .fml .common .event .FMLPostInitializationEvent ;
7
8
import cpw .mods .fml .common .event .FMLPreInitializationEvent ;
@@ -33,7 +34,7 @@ public void preInit(FMLPreInitializationEvent e) {
33
34
@ Override
34
35
public void postInit (FMLPostInitializationEvent e ) {
35
36
super .postInit (e );
36
- chatFuture = FalsePatternLib . getAsyncWorker () .submit (() -> {
37
+ chatFuture = Async . asyncWorker .submit (() -> {
37
38
long start = System .nanoTime ();
38
39
val updates = updatesFuture .get ();
39
40
if (updates == null || updates .size () == 0 ) return null ;
Original file line number Diff line number Diff line change 7
7
import com .falsepattern .lib .internal .Tags ;
8
8
import com .falsepattern .lib .updates .ModUpdateInfo ;
9
9
import com .falsepattern .lib .updates .UpdateChecker ;
10
+ import com .falsepattern .lib .util .Async ;
10
11
import cpw .mods .fml .common .event .FMLConstructionEvent ;
11
12
import cpw .mods .fml .common .event .FMLPostInitializationEvent ;
12
13
import cpw .mods .fml .common .event .FMLPreInitializationEvent ;
@@ -35,7 +36,7 @@ public void preInit(FMLPreInitializationEvent e) {
35
36
if (LibraryConfig .ENABLE_UPDATE_CHECKER ) {
36
37
FalsePatternLib .getLog ().info ("Launching asynchronous update check." );
37
38
val updateCheckFuture = UpdateChecker .fetchUpdatesAsync ("https://falsepattern.com/mc/versions.json" );
38
- updatesFuture = FalsePatternLib . getAsyncWorker () .submit (() -> {
39
+ updatesFuture = Async . asyncWorker .submit (() -> {
39
40
if (!updateCheckFuture .isCancelled ()) {
40
41
try {
41
42
var updates = updateCheckFuture .get ();
Original file line number Diff line number Diff line change 8
8
import com .falsepattern .lib .internal .Internet ;
9
9
import com .falsepattern .lib .internal .LibraryConfig ;
10
10
import com .falsepattern .lib .internal .Tags ;
11
+ import com .falsepattern .lib .util .Async ;
11
12
import cpw .mods .fml .common .Loader ;
12
13
import lombok .val ;
13
14
18
19
import java .util .ArrayList ;
19
20
import java .util .Collections ;
20
21
import java .util .List ;
21
- import java .util .concurrent .ExecutorService ;
22
- import java .util .concurrent .Executors ;
23
22
import java .util .concurrent .Future ;
24
23
import java .util .concurrent .atomic .AtomicInteger ;
25
24
import java .util .concurrent .atomic .AtomicReference ;
@@ -34,7 +33,7 @@ public class UpdateChecker {
34
33
* @return A future that will contain the update info about mods that were both available on the URL and installed
35
34
*/
36
35
public static Future <List <ModUpdateInfo >> fetchUpdatesAsync (String url ) {
37
- return FalsePatternLib . getAsyncWorker () .submit (() -> fetchUpdates (url ));
36
+ return Async . asyncWorker .submit (() -> fetchUpdates (url ));
38
37
}
39
38
40
39
/**
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