Skip to content

Commit

Permalink
set a time limit of 1s for USBTransferThread to join() on shutdown to
Browse files Browse the repository at this point in the history
avoid hangs that require replugging camera
  • Loading branch information
Tobi Delbruck authored and Tobi Delbruck committed Feb 11, 2024
1 parent fc7798c commit b52da71
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeSupport;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.IntBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -43,7 +43,6 @@
import net.sf.jaer.event.EventPacket;
import net.sf.jaer.eventprocessing.EventFilter;
import net.sf.jaer.eventprocessing.FilterChain;
import net.sf.jaer.graphics.AEViewer;
import net.sf.jaer.hardwareinterface.BlankDeviceException;
import net.sf.jaer.hardwareinterface.HardwareInterfaceException;
import net.sf.jaer.hardwareinterface.usb.HasUsbStatistics;
Expand Down Expand Up @@ -664,6 +663,7 @@ public void stopAEReader() {
final AEReader reader = getAeReader();

if (reader != null) {
log.info("Stopping thread "+reader);
reader.stopThread();

setAeReader(null);
Expand Down Expand Up @@ -1039,10 +1039,13 @@ public void stopThread() {
log.warning("USB transfer thread became null before stopThread was called; doing nothing");
return;
}
log.info("Interrupting USBTransferThread "+usbTransfer);
usbTransfer.interrupt();

try {
usbTransfer.join();
log.info("Waiting for USBTransferThread to join()");
usbTransfer.join(Duration.ofSeconds(1));
log.info("USBTransferThread join()'ed");
}
catch (final InterruptedException e) {
CypressFX3.log.severe("Failed to join AEReaderThread");
Expand Down Expand Up @@ -1331,6 +1334,7 @@ public synchronized void setEventAcquisitionEnabled(final boolean enable) throws
startAEReader();
}
else {
log.info("stopping AEReader");
stopAEReader();
}

Expand Down

0 comments on commit b52da71

Please sign in to comment.