| | |
| | | return false; |
| | | } |
| | | taskGuard.lastSubmitTimeMs = now; |
| | | taskGuard.lastQueueEnterTimeMs = now; |
| | | } |
| | | |
| | | try { |
| | |
| | | TaskGuard taskGuard, |
| | | Runnable task) { |
| | | long startMs = System.currentTimeMillis(); |
| | | long queueWaitMs = taskGuard.lastQueueEnterTimeMs > 0L ? startMs - taskGuard.lastQueueEnterTimeMs : 0L; |
| | | try { |
| | | task.run(); |
| | | } catch (Exception e) { |
| | |
| | | } finally { |
| | | long costMs = System.currentTimeMillis() - startMs; |
| | | if (slowLogThresholdMs > 0L && costMs > slowLogThresholdMs) { |
| | | log.warn("MainProcess async task executed slowly, lane={}, task={}, cost={}ms", laneName, taskName, costMs); |
| | | log.warn("MainProcess async task executed slowly, lane={}, task={}, cost={}ms, queueWaitMs={}ms", laneName, taskName, costMs, queueWaitMs); |
| | | } |
| | | taskGuard.running.set(false); |
| | | } |
| | |
| | | |
| | | private final AtomicBoolean running = new AtomicBoolean(false); |
| | | private volatile long lastSubmitTimeMs = 0L; |
| | | private volatile long lastQueueEnterTimeMs = 0L; |
| | | } |
| | | |
| | | private static class NamedThreadFactory implements ThreadFactory { |