/** * Defines a new {@link FlowAsyncTaskAction} instance that task is defined by a class that extends * {@link Runnable}. Whenever a action is triggered a new instance of the given class will be created. Therefore the * class needs a default constructor. All injection that is working in a controller class will work in the given * class that defines the task, too. The task of the action will run on a background thread. Therefore the default * instance of the {@link ObservableExecutor} will be used. * * @param runnableClass the class that defines the task */ public FlowAsyncTaskAction(Class<? extends Runnable> runnableClass) { this(runnableClass, ObservableExecutor.getDefaultInstance()); }
/** * 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); }
/** * Returns the default executor. This one uses an internal cached thread pool. * @return the default executor */ public static synchronized ObservableExecutor getDefaultInstance() { if(defaultInstance == null) { //TODO: support of system properties to define the inner executor defaultInstance = new ObservableExecutor(); } return defaultInstance; } }
@Override protected void executeTask(Task<V> task) { cancelable.unbind(); if (task instanceof DataFxTask) { cancelable.bind(((DataFxTask<V>) task).cancelableProperty()); } Executor e = getExecutor(); if (e != null) { e.execute(task); } else { ObservableExecutor.getDefaultInstance().execute(task); } }
for (EventProducerImpl eventProducer : eventProducers) { if (eventProducer.getThreadType().equals(ThreadType.EXECUTOR)) { ObservableExecutor.getDefaultInstance().execute(() -> { EventSystem.getInstance().send(eventProducer.getAdress(), eventProducer.getContentSupplier().get()); });
/** * Defines a new {@link FlowAsyncTaskAction} instance that task is defined by a {@link Runnable} instance. The task * of the action will run on a background thread. Therefore the default instance of the {@link ObservableExecutor} * will be used. * * @param runnable defines the task and will be called whenever the action is triggered. */ public FlowAsyncTaskAction(Runnable runnable) { this(runnable, ObservableExecutor.getDefaultInstance()); }
/** * 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)); }
public CrudObjectProperty(S entity, CrudListProperty<S, T> listProperty, CrudService<S, T> crudService) { this(entity, crudService, ObservableExecutor.getDefaultInstance()); this.listProperty = listProperty; }
/** * 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)); }
@Override public ObservableExecutor getResource(ConcurrencyProvider annotation, Class<ObservableExecutor> cls, ViewContext<?> context) { return ObservableExecutor.getDefaultInstance(); }
/** * 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 CrudListProperty(CrudService<S, T> crudService) { this(crudService, ObservableExecutor.getDefaultInstance()); }
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; } }
public CrudObjectProperty(CrudService<S, T> crudService) { this(crudService, ObservableExecutor.getDefaultInstance()); }
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(); } }
/** * default constructor */ private EventSystem() { consumers = FXCollections.observableHashMap(); asyncConsumers = FXCollections.observableHashMap(); exceptionHandler = ExceptionHandler.getDefaultInstance(); executor = ObservableExecutor.getDefaultInstance(); }