/** * Convenience method used when only the function is given. * * @param afn the code to call on each iteration * @return the newly created thread */ public static SmartThread asyncLoop(final Callable afn) { return asyncLoop(afn, false, null, Thread.NORM_PRIORITY, false, true, null); }
/** * Convenience method used when only the function and name suffix are given. * * @param afn the code to call on each iteration * @param threadName a suffix to be appended to the thread name * @return the newly created thread * * @see Thread */ public static SmartThread asyncLoop(final Callable afn, String threadName, final Thread.UncaughtExceptionHandler eh) { return asyncLoop(afn, false, eh, Thread.NORM_PRIORITY, false, true, threadName); }
public SmartThread makeTransferThread() { return Utils.asyncLoop(() -> { if (transferQueue.consume(this) == 0) { return 1L; } return 0L; }); }
/** * separated from mkExecutor in order to replace executor transfer in executor data for testing. */ public ExecutorShutdown execute() throws Exception { LOG.info("Loading executor tasks " + componentId + ":" + executorId); String handlerName = componentId + "-executor" + executorId; Utils.SmartThread handler = Utils.asyncLoop(this, false, reportErrorDie, Thread.NORM_PRIORITY, true, true, handlerName); LOG.info("Finished loading executor " + componentId + ":" + executorId); return new ExecutorShutdown(this, Lists.newArrayList(handler), idToTask, receiveQueue); }
Utils.asyncLoop(new Callable<Long>() { public Long call() { if (logPrefix != null) {
/** * Convenience method used when only the function is given. * @param afn the code to call on each iteration * @return the newly created thread */ public static SmartThread asyncLoop(final Callable afn) { return asyncLoop(afn, false, null, Thread.NORM_PRIORITY, false, true, null); }
/** * Convenience method used when only the function and name suffix are given. * @param afn the code to call on each iteration * @param threadName a suffix to be appended to the thread name * @return the newly created thread * @see java.lang.Thread */ public static SmartThread asyncLoop(final Callable afn, String threadName, final Thread.UncaughtExceptionHandler eh) { return asyncLoop(afn, false, eh, Thread.NORM_PRIORITY, false, true, threadName); }
Utils.asyncLoop(new Callable<Object>() { public Object call() { if (logPrefix != null ) {