예제 #1
0
 @Override
 public void safeRun() {
   taskPendingStats.registerSuccessfulEvent(initNanos, TimeUnit.NANOSECONDS);
   long startNanos = MathUtils.nowInNano();
   this.runnable.safeRun();
   long elapsedMicroSec = MathUtils.elapsedMicroSec(startNanos);
   taskExecutionStats.registerSuccessfulEvent(elapsedMicroSec, TimeUnit.MICROSECONDS);
   if (elapsedMicroSec >= warnTimeMicroSec) {
     logger.warn(
         "Runnable {}:{} took too long {} micros to execute.",
         new Object[] {runnable, runnable.getClass(), elapsedMicroSec});
   }
 }
예제 #2
0
 TimedRunnable(SafeRunnable runnable) {
   this.runnable = runnable;
   this.initNanos = MathUtils.nowInNano();
 }