/** * Execute the given runnable at some time in the future. * * @param runnable the runnable. If a <code>DataFxRunnable</code> is used * here a <code>TaskStateHandler</code> will be injected. */ public void execute(Runnable runnable) { submit(runnable); }
/** * Execute the given runnable at some time in the future. * * @param runnable the runnable. If a <code>DataFxRunnable</code> is used * here a <code>TaskStateHandler</code> will be injected. * @return a worker that can be used to check the state of the runnable */ public Worker<Void> submit(final Runnable runnable) { return submit(ConcurrentUtils.createService(runnable)); }
/** * Execute the given task at some time in the future. * * @param <T> the return type for the task * @param task the task. * @return a worker that can be used to check the state of the task and * receive the result of it. */ public <T> Worker<T> submit(final Task<T> task) { return submit(ConcurrentUtils.createService(task)); }
/** * Execute the given callable at some time in the future. * * @param <T> the return type for the worker * @param callable the callable. If a <code>DataFxCallable</code> is used * here a <code>TaskStateHandler</code> will be injected. * @return a worker that can be used to check the state of the callable and * receive the result of it. */ public <T> Worker<T> submit(final Callable<T> callable) { return submit(ConcurrentUtils.createService(callable)); }
public static <T> Worker<T> executeService(Executor executor, Service<T> service) { if (executor != null && executor instanceof ObservableExecutor) { return ((ObservableExecutor) executor).submit(service); } else { if (executor != null) { service.setExecutor(executor); } service.start(); return service; } }
private void handleKeepReading (final ServerSentEventReader reader) { Service retriever = createKeepReadingService(reader); if (executor != null && executor instanceof ObservableExecutor) { ((ObservableExecutor) executor).submit(retriever); } else { if (executor != null) { retriever.setExecutor(executor); } retriever.start(); } }