Skip to content

Commit

Permalink
open offer manager completes shut down after thread pool
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Feb 1, 2024
1 parent 98bb77b commit 6868382
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions core/src/main/java/haveno/core/offer/OpenOfferManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,20 @@ public void shutDown(@Nullable Runnable completeHandler) {
// Force broadcaster to send out immediately, otherwise we could have a 2 sec delay until the
// bundled messages sent out.
broadcaster.flush();

if (completeHandler != null) {
// For typical number of offers we are tolerant with delay to give enough time to broadcast.
// If number of offers is very high we limit to 3 sec. to not delay other shutdown routines.
int delay = Math.min(3000, size * 200 + 500);
UserThread.runAfter(completeHandler, delay, TimeUnit.MILLISECONDS);
}
// For typical number of offers we are tolerant with delay to give enough time to broadcast.
// If number of offers is very high we limit to 3 sec. to not delay other shutdown routines.
long delayMs = Math.min(3000, size * 200 + 500);
GenUtils.waitFor(delayMs);;
}, THREAD_ID);
} else {
broadcaster.flush();
if (completeHandler != null)
completeHandler.run();
}

// shut down thread pool
shutDownThreadPool();

// invoke completion handler
if (completeHandler != null) completeHandler.run();
}

private void shutDownThreadPool() {
Expand Down

0 comments on commit 6868382

Please sign in to comment.