open offer manager completes shut down after thread pool

This commit is contained in:
woodser 2024-02-01 11:04:51 -05:00
parent 902accb290
commit fabec9d396

View file

@ -331,20 +331,20 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
// Force broadcaster to send out immediately, otherwise we could have a 2 sec delay until the // Force broadcaster to send out immediately, otherwise we could have a 2 sec delay until the
// bundled messages sent out. // bundled messages sent out.
broadcaster.flush(); broadcaster.flush();
// For typical number of offers we are tolerant with delay to give enough time to broadcast.
if (completeHandler != null) { // If number of offers is very high we limit to 3 sec. to not delay other shutdown routines.
// For typical number of offers we are tolerant with delay to give enough time to broadcast. long delayMs = Math.min(3000, size * 200 + 500);
// If number of offers is very high we limit to 3 sec. to not delay other shutdown routines. GenUtils.waitFor(delayMs);;
int delay = Math.min(3000, size * 200 + 500);
UserThread.runAfter(completeHandler, delay, TimeUnit.MILLISECONDS);
}
}, THREAD_ID); }, THREAD_ID);
} else { } else {
broadcaster.flush(); broadcaster.flush();
if (completeHandler != null)
completeHandler.run();
} }
// shut down thread pool
shutDownThreadPool(); shutDownThreadPool();
// invoke completion handler
if (completeHandler != null) completeHandler.run();
} }
private void shutDownThreadPool() { private void shutDownThreadPool() {