Skip to content

Commit

Permalink
shut down open offer pool off ui thread to avoid blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Feb 19, 2024
1 parent 2e9e0fa commit e2463f4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions core/src/main/java/haveno/core/offer/OpenOfferManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,17 +351,19 @@ public void shutDown(@Nullable Runnable completeHandler) {
// 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);;
GenUtils.waitFor(delayMs);
}, THREAD_ID);
} else {
broadcaster.flush();
}

// shut down thread pool
shutDownThreadPool();

// invoke completion handler
if (completeHandler != null) completeHandler.run();
// shut down thread pool off main thread
ThreadUtils.submitToPool(() -> {
shutDownThreadPool();

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

private void shutDownThreadPool() {
Expand Down

0 comments on commit e2463f4

Please sign in to comment.