You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implemented unsafe asynchronous mode, allowing the bot to read directly from live game data while the frame buffer is being populated. There's some additional cruft lying around and there's no guarantee that this will actually work in practice, but the test case is passing.
Copy file name to clipboardExpand all lines: src/main/java/bwapi/BWClientConfiguration.java
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,16 @@ public class BWClientConfiguration {
50
50
* The maximum number of frames to buffer while waiting on a bot.
51
51
* Each frame buffered adds about 33 megabytes to JBWAPI's memory footprint.
52
52
*/
53
-
publicintasyncFrameBufferSize = 10;
53
+
publicintasyncFrameBufferCapacity = 10;
54
+
55
+
/**
56
+
* Enables thread-unsafe async mode.
57
+
* In this mode, the bot is allowed to read directly from shared memory until shared memory has been copied into the frame buffer,
58
+
* at wihch point the bot switches to using the frame buffer.
59
+
* This should enhance performance by allowing the bot to act while the frame is copied, but poses unidentified risk due to
60
+
* the non-thread-safe switc from shared memory reads to frame buffer reads.
61
+
*/
62
+
publicbooleanasyncUnsafe = false;
54
63
55
64
/**
56
65
* Toggles verbose logging, particularly of synchronization steps.
@@ -64,8 +73,8 @@ public void validate() {
64
73
if (async && maxFrameDurationMs < 0) {
65
74
thrownewIllegalArgumentException("maxFrameDurationMs needs to be a non-negative number (it's how long JBWAPI waits for a bot response before returning control to BWAPI).");
66
75
}
67
-
if (async && asyncFrameBufferSize < 1) {
68
-
thrownewIllegalArgumentException("asyncFrameBufferSize needs to be a positive number (There needs to be at least one frame buffer).");
76
+
if (async && asyncFrameBufferCapacity < 1) {
77
+
thrownewIllegalArgumentException("asyncFrameBufferCapacity needs to be a positive number (There needs to be at least one frame buffer).");
0 commit comments