.modules(ImmutableList.<Module>of( new SLF4JLoggingModule(), new ExecutorServiceModule(executorService))) .overrides(properties); if (!Strings.isNullOrEmpty(endpoint)) {
@Provides @Singleton @Named(PROPERTY_USER_THREADS) ListeningExecutorService provideListeningUserExecutorService(@Named(PROPERTY_USER_THREADS) int count, Closer closer) { // NO_UCD if (userExecutorFromConstructor != null) return userExecutorFromConstructor; return shutdownOnClose(WithSubmissionTrace.wrap(newThreadPoolNamed("user thread %d", count)), closer); }
private ListeningExecutorService newCachedThreadPoolNamed(String name) { return listeningDecorator(Executors.newCachedThreadPool(namedThreadFactory(name))); }
private ListeningExecutorService newThreadPoolNamed(String name, int maxCount) { return maxCount == 0 ? newCachedThreadPoolNamed(name) : newScalingThreadPoolNamed(name, maxCount); }
@Provides @Singleton @Named(PROPERTY_SCHEDULER_THREADS) ListeningScheduledExecutorService provideListeningScheduledExecutorService( @Named(PROPERTY_SCHEDULER_THREADS) int count, Closer closer) { return shutdownOnClose(WithSubmissionTrace.wrap(newScheduledThreadPoolNamed("scheduler thread %d", count)), closer); }
private ListeningExecutorService newThreadPoolNamed(String name, int maxCount) { return maxCount == 0 ? newCachedThreadPoolNamed(name) : newScalingThreadPoolNamed(name, maxCount); }
@Provides @Singleton @Named(PROPERTY_SCHEDULER_THREADS) ListeningScheduledExecutorService provideListeningScheduledExecutorService( @Named(PROPERTY_SCHEDULER_THREADS) int count, Closer closer) { return shutdownOnClose(WithSubmissionTrace.wrap(newScheduledThreadPoolNamed("scheduler thread %d", count)), closer); }
@VisibleForTesting static void addExecutorServiceIfNotPresent(List<Module> modules) { if (!any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class); } } )) { if (any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(SingleThreaded.class); } })) { modules.add(new ExecutorServiceModule(sameThreadExecutor())); } else { modules.add(new ExecutorServiceModule()); } } }
@Provides @Singleton @Named(PROPERTY_IO_WORKER_THREADS) ListeningExecutorService provideListeningIOExecutorService(@Named(PROPERTY_IO_WORKER_THREADS) int count, Closer closer) { // NO_UCD if (ioExecutorFromConstructor != null) return ioExecutorFromConstructor; return shutdownOnClose(WithSubmissionTrace.wrap(newThreadPoolNamed("i/o thread %d", count)), closer); }
private ListeningExecutorService newThreadPoolNamed(String name, int maxCount) { return maxCount == 0 ? newCachedThreadPoolNamed(name) : newScalingThreadPoolNamed(name, maxCount); }
@Provides @Singleton @Named(PROPERTY_SCHEDULER_THREADS) ListeningScheduledExecutorService provideListeningScheduledExecutorService( @Named(PROPERTY_SCHEDULER_THREADS) int count, Closer closer) { return shutdownOnClose(WithSubmissionTrace.wrap(newScheduledThreadPoolNamed("scheduler thread %d", count)), closer); }
private ListeningExecutorService newCachedThreadPoolNamed(String name) { return listeningDecorator(Executors.newCachedThreadPool(namedThreadFactory(name))); }
@VisibleForTesting static void addExecutorServiceIfNotPresent(List<Module> modules) { if (!any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class); } } )) { if (any(modules, new Predicate<Module>() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(SingleThreaded.class); } })) { modules.add(new ExecutorServiceModule(sameThreadExecutor())); } else { modules.add(new ExecutorServiceModule()); } } }
@Provides @Singleton @Named(PROPERTY_USER_THREADS) ListeningExecutorService provideListeningUserExecutorService(@Named(PROPERTY_USER_THREADS) int count, Closer closer) { // NO_UCD if (userExecutorFromConstructor != null) return userExecutorFromConstructor; return shutdownOnClose(WithSubmissionTrace.wrap(newThreadPoolNamed("user thread %d", count)), closer); }
private ListeningExecutorService newThreadPoolNamed(String name, int maxCount) { return maxCount == 0 ? newCachedThreadPoolNamed(name) : newScalingThreadPoolNamed(name, maxCount); }
@Provides @Singleton @Named(PROPERTY_SCHEDULER_THREADS) final ListeningScheduledExecutorService provideListeningScheduledExecutorService( @Named(PROPERTY_SCHEDULER_THREADS) int count, Closer closer) { return shutdownOnClose(WithSubmissionTrace.wrap(newScheduledThreadPoolNamed("scheduler thread %d", count)), closer); }
private ListeningExecutorService newCachedThreadPoolNamed(String name) { return listeningDecorator(Executors.newCachedThreadPool(namedThreadFactory(name))); }
public GoogleAppEngineConfigurationModule() { this(new ExecutorServiceModule(newDirectExecutorService())); }
@Provides @Singleton @Named(PROPERTY_USER_THREADS) ListeningExecutorService provideListeningUserExecutorService(@Named(PROPERTY_USER_THREADS) int count, Closer closer) { // NO_UCD if (userExecutorFromConstructor != null) return userExecutorFromConstructor; return shutdownOnClose(WithSubmissionTrace.wrap(newThreadPoolNamed("user thread %d", count)), closer); }
private ListeningExecutorService newThreadPoolNamed(String name, int maxCount) { return maxCount == 0 ? newCachedThreadPoolNamed(name) : newScalingThreadPoolNamed(name, maxCount); }