Skip to content

Commit b735923

Browse files
committed
Removed unnecessary allocations in Game API.
1 parent 71dbc8d commit b735923

File tree

4 files changed

+83
-88
lines changed

4 files changed

+83
-88
lines changed

src/main/java/bwapi/BWClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class BWClient {
1717
public BWClient(final BWEventListener eventListener) {
1818
Objects.requireNonNull(eventListener);
1919
this.eventListener = eventListener;
20-
this.timerResolutionThread = new TimerResolutionThread();
20+
//this.timerResolutionThread = new TimerResolutionThread();
2121
}
2222

2323
/**
@@ -81,7 +81,7 @@ public void startGame(BWClientConfiguration configuration) {
8181

8282
// Use reduced priority to encourage Windows to give priority to StarCraft.exe/BWAPI.
8383
// If BWAPI doesn't get priority, it may not detect completion of a frame on our end in timely fashion.
84-
Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
84+
Thread.currentThread().setPriority(4);
8585

8686
if (client == null) {
8787
client = new Client(configuration);

src/main/java/bwapi/BotWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void onFrame() {
8282
botThread = createBotThread();
8383
botThread.setName("JBWAPI Bot");
8484
// Reduced priority helps ensure that StarCraft.exe/BWAPI pick up on our frame completion in timely fashion
85-
botThread.setPriority(Thread.MIN_PRIORITY);
85+
botThread.setPriority(3);
8686
botThread.start();
8787
}
8888

src/main/java/bwapi/Client.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,13 @@ void update() {
247247
while (code != 2) {
248248
try {
249249
code = pipeObjectHandle.readByte();
250+
/*
250251
if (code != 2) {
251-
Thread.sleep(0, 1);
252+
try {
253+
Thread.sleep(0, 1);
254+
} catch (InterruptedException ignored) {}
252255
}
256+
*/
253257
}
254258
catch (Exception e) {
255259
System.err.println("failed, disconnecting");

0 commit comments

Comments
 (0)