mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 07:12:17 +00:00
Adjust user thread queue size warning.
This commit is contained in:
parent
829656b153
commit
b6149bfa48
@ -86,6 +86,9 @@ public class Threading {
|
||||
|
||||
public static class UserThread extends Thread implements Executor {
|
||||
private static final Logger log = LoggerFactory.getLogger(UserThread.class);
|
||||
// 10,000 pending tasks is entirely arbitrary and may or may not be appropriate for the device we're
|
||||
// running on.
|
||||
public static int WARNING_THRESHOLD = 10000;
|
||||
private LinkedBlockingQueue<Runnable> tasks;
|
||||
|
||||
public UserThread() {
|
||||
@ -112,10 +115,13 @@ public class Threading {
|
||||
|
||||
@Override
|
||||
public void execute(Runnable command) {
|
||||
if (tasks.size() > 100) {
|
||||
log.warn("User thread saturated, memory exhaustion may occur.");
|
||||
log.warn("Check for deadlocked or slow event handlers. Sample tasks:");
|
||||
for (Object task : tasks.toArray()) log.warn(task.toString());
|
||||
final int size = tasks.size();
|
||||
if (size > WARNING_THRESHOLD) {
|
||||
log.warn(
|
||||
"User thread has {} pending tasks, memory exhaustion may occur.\n" +
|
||||
"If you see this message, check your memory consumption and see if it's problematic or excessively spikey.\n" +
|
||||
"If it is, check for deadlocked or slow event handlers. If it isn't, try adjusting the constant \n" +
|
||||
"Threading.UserThread.WARNING_THRESHOLD upwards until it's a suitable level for your app, or Integer.MAX_VALUE to disable." , size);
|
||||
}
|
||||
Uninterruptibles.putUninterruptibly(tasks, command);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user