Skip to content

Commit 93c88ae

Browse files
authored
Merge branch 'master' into safe-mode
2 parents 7cc760d + 1ff25a1 commit 93c88ae

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# FRC Team 199 Library
22

33
This projects builds `lib199.jar` which contains code that reuse across projects/years. The javadocs can be found [here](https://deepbluerobotics.github.io/lib199/).
4+
5+
## Changelog
6+
A changelog is automatically generated with each release and is available on the [Releases](https://github.com/DeepBlueRobotics/lib199/releases) page. Please write documentation for all changes and, if significant enough, add appropriate information to the [programming training website](https://deep-blue-training.readthedocs.io/en/latest/).

src/test/java/org/carlmontrobotics/lib199/MotorErrorsTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.junit.Assert.assertTrue;
66
import static org.junit.Assume.assumeNoException;
77

8+
import java.util.concurrent.CountDownLatch;
89
import java.util.concurrent.atomic.AtomicBoolean;
910

1011
import com.ctre.phoenix.ErrorCode;
@@ -234,21 +235,28 @@ private void doTestReportSparkMaxTemp(int id) {
234235
private AutoCloseable blockAsyncPeriodic() {
235236
AtomicBoolean block = new AtomicBoolean(true);
236237
Object lock = new Object();
238+
CountDownLatch latch = new CountDownLatch(1);
237239
Lib199Subsystem.registerAsyncPeriodic(() -> {
238240
synchronized(lock) {
239-
while(block.get()) {
241+
latch.countDown(); // Signal that we've started blocking
242+
while(block.get()) { // Block until released
240243
try {
241-
lock.wait();
244+
lock.wait(); // Wait for the block to be released
242245
} catch(InterruptedException e) {
243246
assumeNoException(e);
244247
}
245248
}
246249
}
247250
});
251+
try {
252+
latch.await(); // Wait for the async thread to start blocking
253+
} catch(InterruptedException e) {
254+
assumeNoException(e);
255+
}
248256
return () -> {
249-
block.set(false);
257+
block.set(false); // Release the block
250258
synchronized(lock) {
251-
lock.notifyAll();
259+
lock.notifyAll(); // Notify the async thread that the block has been released
252260
}
253261
};
254262
}

0 commit comments

Comments
 (0)