/** * Builds a new {@link ImmutableThreadFactoryProvider ImmutableThreadFactoryProvider}. * @return An immutable instance of ThreadFactoryProvider * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableThreadFactoryProvider build() { checkRequiredAttributes(); return new ImmutableThreadFactoryProvider(this); }
@Override public ListenableFuture<?> submit(final Runnable task) { return wrapListenableFuture(super.submit(wrapRunnable(task))); }
@Override public <T> ListenableFuture<T> submit(final Callable<T> task) { return wrapListenableFuture(super.submit(wrapCallable(task))); }
public long getLargestQueueSize() { return ((TrackingLinkedBlockingQueue<?>)getQueue()).getLargestQueueSize(); }
public long getLargestQueueSize() { return executorQueue.getBackingQueue().getLargestQueueSize(); }
@Override public void addListener(final Runnable listener, final Executor executor) { // Wrap the listener Runnable in a DelegatingRunnable. If the specified executor is one that // runs tasks in the same thread as the caller submitting the task // (e.g. {@link com.google.common.util.concurrent.MoreExecutors#sameThreadExecutor}) and the // listener is executed from the #done method, then the DelegatingRunnable will detect this // via the ThreadLocal and submit the listener Runnable to the listenerExecutor. // // On the other hand, if this task is already complete, the call to ExecutionList#add in // superclass will execute the listener Runnable immediately and, since the ThreadLocal won't be set, // the DelegatingRunnable will run the listener Runnable inline. super.addListener(new DelegatingRunnable(listener, listenerExecutor), executor); } }
/** * Copy the current immutable object by setting a value for the {@link ThreadFactoryProvider#daemon() daemon} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for daemon * @return A modified copy of the {@code this} object */ public final ImmutableThreadFactoryProvider withDaemon(boolean value) { if (this.daemon == value) return this; return new ImmutableThreadFactoryProvider(this.namePrefix, this.logger, this.priority, value); }
/** * Remove the state which may have attached to the calling thread. If no state * was attached this method does nothing. */ public static void cleanStateForCurrentThread() { ON_TASK_COMPLETION_THREAD_TL.remove(); }
InMemoryDOMDataTreeShardChangePublisher(final Executor executor, final int maxQueueSize, final DataTree dataTree, final YangInstanceIdentifier rootPath, final Map<DOMDataTreeIdentifier, ChildShardContext> childShards) { super(dataTree, rootPath, childShards); notificationManager = QueuedNotificationManager.create(executor, MANAGER_INVOKER, maxQueueSize, "DataTreeChangeListenerQueueMgr"); }
@Override public FluentFuture<Boolean> apply(final SchemaSourceRepresentation schemaSource) { return FluentFutures.immediateTrueFluentFuture(); } };
@Override public List<ListenerNotificationQueueStats> getCurrentListenerQueueStats() { return manager.getListenerNotificationQueueStats(); }
@Override public <T> ListenableFuture<T> submit(final Runnable task, final T result) { return wrapListenableFuture(super.submit(wrapRunnable(task), result)); }
@Override public <T> ListenableFuture<T> submit(final Callable<T> task) { return wrapListenableFuture(super.submit(wrapCallable(task))); }
public long getLargestQueueSize() { return ((TrackingLinkedBlockingQueue<?>)getQueue()).getLargestQueueSize(); }
public long getLargestQueueSize() { return executorQueue.getBackingQueue().getLargestQueueSize(); }
@Override public void addListener(final Runnable listener, final Executor executor) { // Wrap the listener Runnable in a DelegatingRunnable. If the specified executor is one that // runs tasks in the same thread as the caller submitting the task // (e.g. {@link com.google.common.util.concurrent.MoreExecutors#sameThreadExecutor}) and the // listener is executed from the #done method, then the DelegatingRunnable will detect this // via the ThreadLocal and submit the listener Runnable to the listenerExecutor. // // On the other hand, if this task is already complete, the call to ExecutionList#add in // superclass will execute the listener Runnable immediately and, since the ThreadLocal won't be set, // the DelegatingRunnable will run the listener Runnable inline. super.addListener(new DelegatingRunnable(listener, listenerExecutor), executor); } }
/** * Construct a new immutable {@code ThreadFactoryProvider} instance. * @param namePrefix The value for the {@code namePrefix} attribute * @param logger The value for the {@code logger} attribute * @param priority The value for the {@code priority} attribute * @return An immutable ThreadFactoryProvider instance */ public static ImmutableThreadFactoryProvider of(String namePrefix, Logger logger, Optional<Integer> priority) { return new ImmutableThreadFactoryProvider(namePrefix, logger, priority); }
/** * Remove the state which may have attached to the calling thread. If no state * was attached this method does nothing. */ public static void cleanStateForCurrentThread() { ON_TASK_COMPLETION_THREAD_TL.remove(); }
@Override public ListenableFuture<?> submit(final Runnable task) { return wrapListenableFuture(super.submit(wrapRunnable(task))); }
@Override public <T> ListenableFuture<T> submit(final Runnable task, final T result) { return wrapListenableFuture(super.submit(wrapRunnable(task), result)); }