public AsyncValueUpdatingSupplier( final FibersExecutor executor, final T initialValue, final InitCallable<T> updateAction) throws NullPointerException { super(initialValue, null); if (updateAction == null) { throw new NullPointerException("Argument should not be null"); } updateTask = new ExclusiveFiberBase(executor) { @Override protected final void invokeTimedExclusively(final long startTimeNanos) { try { lastValue = updateAction.call(); } catch (final Exception e) { LogUtil.trace( Loggers.ERR, Level.WARN, e, "Failed to execute the value update action"); } } @Override protected final void doClose() { lastValue = null; } }; try { updateTask.start(); } catch (final RemoteException ignored) { } }
public static void main(final String... args) throws InterruptedException, IOException { final FibersExecutor executor = new FibersExecutor(); final Fiber helloFiber = new HelloWorldFiber(executor); helloFiber.start(); TimeUnit.SECONDS.sleep(10); helloFiber.close(); } }
@Override protected void doStart() throws IllegalStateException { try { resultsTransferTask.start(); } catch (final RemoteException ignored) { } try { driver.start(); } catch (final RemoteException ignored) { } catch (final IllegalStateException e) { LogUtil.exception(Level.WARN, e, "{}: failed to start the storage driver \"{}\"", id, driver); } try { generator.start(); } catch (final RemoteException ignored) { } catch (final IllegalStateException e) { LogUtil.exception( Level.WARN, e, "{}: failed to start the load generator \"{}\"", id, generator); } }