Example usage for com.google.common.util.concurrent MoreExecutors newDirectExecutorService

List of usage examples for com.google.common.util.concurrent MoreExecutors newDirectExecutorService

Introduction

In this page you can find the example usage for com.google.common.util.concurrent MoreExecutors newDirectExecutorService.

Prototype

@GwtIncompatible("TODO")
public static ListeningExecutorService newDirectExecutorService() 

Source Link

Document

Creates an executor service that runs each task in the thread that invokes execute/submit , as in CallerRunsPolicy This applies both to individually submitted tasks and to collections of tasks submitted via invokeAll or invokeAny .

Usage

From source file:org.jclouds.b2.features.B2TestUtils.java

static B2Api api(String uri, String provider, Properties overrides) {
    Set<Module> modules = ImmutableSet
            .<Module>of(new ExecutorServiceModule(MoreExecutors.newDirectExecutorService()));

    return ContextBuilder.newBuilder(provider).credentials("ACCOUNT_ID", "APPLICATION_KEY").endpoint(uri)
            .overrides(overrides).modules(modules).buildApi(B2Api.class);
}

From source file:com.facebook.buck.rules.query.DepQueryUtils.java

public static Stream<BuildRule> resolveDepQuery(BuildRuleParams params, String query,
        BuildRuleResolver resolver, TargetGraph targetGraph) {
    BuildTarget target = params.getBuildTarget();
    Set<BuildTarget> declaredDeps = params.getDeclaredDeps().get().stream().map(BuildRule::getBuildTarget)
            .collect(Collectors.toSet());
    GraphEnhancementQueryEnvironment env = new GraphEnhancementQueryEnvironment(Optional.of(resolver),
            Optional.of(targetGraph), params.getCellRoots(), target, declaredDeps);
    ListeningExecutorService executorService = MoreExecutors.newDirectExecutorService();
    try {/*ww w .ja  va2  s .  c o m*/
        QueryExpression parsedExp = QueryExpression.parse(query, env);
        Set<QueryTarget> queryTargets = parsedExp.eval(env, executorService);
        return queryTargets.stream().map(queryTarget -> {
            Preconditions.checkState(queryTarget instanceof QueryBuildTarget);
            return resolver.getRule(((QueryBuildTarget) queryTarget).getBuildTarget());
        });
    } catch (QueryException e) {
        throw new RuntimeException("Error parsing/executing query from deps for " + target, e);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new RuntimeException("Error executing query from deps for " + target, e);
    }
}

From source file:org.opendaylight.controller.md.sal.binding.test.ConcurrentDataBrokerTestCustomizer.java

public ConcurrentDataBrokerTestCustomizer(boolean useMTDataTreeChangeListenerExecutor) {
    if (useMTDataTreeChangeListenerExecutor) {
        dataTreeChangeListenerExecutorSingleton = MoreExecutors
                .listeningDecorator(Executors.newCachedThreadPool());
    } else {//from   w ww .ja va2 s.  c  om
        dataTreeChangeListenerExecutorSingleton = MoreExecutors.newDirectExecutorService();
    }
}

From source file:org.mule.config.DirectThreadingProfile.java

@Override
public ExecutorService createPool(String name) {
    return MoreExecutors.newDirectExecutorService();
}

From source file:com.facebook.buck.android.AndroidInstrumentationApkBuilder.java

private AndroidInstrumentationApkBuilder(BuildTarget target) {
    super(new AndroidInstrumentationApkDescription(new ProGuardConfig(FakeBuckConfig.builder().build()),
            ANDROID_JAVAC_OPTIONS, ImmutableMap.of(), MoreExecutors.newDirectExecutorService(),
            new CxxBuckConfig(new FakeBuckConfig.Builder().build())), target);
}

From source file:de.ks.idnadrev.expimp.xls.XlsxExporter.java

public XlsxExporter() {
    this(MoreExecutors.newDirectExecutorService());
}

From source file:com.facebook.buck.rules.macros.QueryMacroExpander.java

public QueryMacroExpander(Optional<TargetGraph> targetGraph) {
    this.targetGraph = targetGraph;
    this.executorService = MoreExecutors.newDirectExecutorService();
}

From source file:de.ks.idnadrev.expimp.xls.XlsxImporter.java

public XlsxImporter() {
    this(MoreExecutors.newDirectExecutorService());
}

From source file:com.facebook.buck.distributed.LocalFsContentsProvider.java

public LocalFsContentsProvider(ProjectFilesystemFactory projectFilesystemFactory, Path cacheDirAbsPath)
        throws InterruptedException, IOException {
    Preconditions.checkArgument(Files.isDirectory(cacheDirAbsPath),
            "The cache directory must exist. cacheDirAbsPath=[%s]", cacheDirAbsPath);
    this.dirCache = new DirArtifactCache(CACHE_NAME,
            projectFilesystemFactory.createProjectFilesystem(cacheDirAbsPath), Paths.get(CACHE_NAME),
            CacheReadMode.READWRITE, Optional.empty(), MoreExecutors.newDirectExecutorService());
}

From source file:com.facebook.buck.rules.CachingBuildEngineFactory.java

public CachingBuildEngineFactory(BuildRuleResolver buildRuleResolver) {
    this.cachingBuildEngineDelegate = new LocalCachingBuildEngineDelegate(new NullFileHashCache());
    this.executorService = toWeighted(MoreExecutors.newDirectExecutorService());
    this.buildRuleResolver = buildRuleResolver;
}