Skip to content

Commit 7ec37f3

Browse files
author
Jasper Geurtz
committed
only-async
1 parent 7db7bf0 commit 7ec37f3

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
<version>3.2.5</version>
6363
<configuration>
6464
<rerunFailingTestsCount>1</rerunFailingTestsCount>
65-
<argLine>--add-opens java.base/java.nio=ALL-UNNAMED -Xms1g -Xmx1g</argLine>
65+
<!-- <argLine>&#45;&#45;add-opens java.base/java.nio=ALL-UNNAMED -Xms1g -Xmx1g</argLine>-->
66+
<argLine>-Xms1g -Xmx1g</argLine>
6667
</configuration>
6768
</plugin>
6869
<plugin>

src/main/java/bwapi/BotWrapperAsync.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class BotWrapperAsync extends BotWrapper {
2222
// Use reduced priority to encourage Windows to give priority to StarCraft.exe/BWAPI.
2323
// If BWAPI doesn't get priority, it may not detect completion of a frame on our end in timely fashion.
2424
Thread.currentThread().setName("JBWAPI Client");
25-
Thread.currentThread().setPriority(4);
25+
Thread.currentThread().setPriority(Thread.NORM_PRIORITY - 1);
2626
}
2727

2828
/**
@@ -35,12 +35,13 @@ void startNewGame(WrappedBuffer liveData, PerformanceMetrics performanceMetrics)
3535
liveClientData.setBuffer(liveData);
3636
this.liveData = liveData;
3737

38-
configuration.log("Main: Starting bot thread");
39-
botThread = createBotThread();
40-
botThread.setName("JBWAPI Bot");
41-
// Reduced priority helps ensure that StarCraft.exe/BWAPI pick up on our frame completion in timely fashion
42-
botThread.setPriority(3);
43-
botThread.start();
38+
// configuration.log("Main: Starting bot thread");
39+
// botThread = createBotThread();
40+
// botThread.setName("JBWAPI Bot");
41+
// // Reduced priority helps ensure that StarCraft.exe/BWAPI pick up on our frame completion in timely fashion
42+
// botThread.setPriority(Thread.NORM_PRIORITY - 2);
43+
// botThread.start();
44+
botThread = null;
4445
}
4546

4647

@@ -81,6 +82,15 @@ void asyncOnFrame() {
8182
long startNanos = System.nanoTime();
8283
long endNanos = startNanos + (long) configuration.getMaxFrameDurationMs() * 1000000;
8384

85+
if (botThread == null) {
86+
configuration.log("Main: Starting bot thread");
87+
botThread = createBotThread();
88+
botThread.setName("JBWAPI Bot");
89+
// Reduced priority helps ensure that StarCraft.exe/BWAPI pick up on our frame completion in timely fashion
90+
botThread.setPriority(3);
91+
botThread.start();
92+
}
93+
8494
// Unsafe mode:
8595
// If the frame buffer is empty (meaning the bot must be idle)
8696
// allow the bot to read directly from shared memory while we copy it over

0 commit comments

Comments
 (0)