Example usage for java.util.concurrent CompletableFuture supplyAsync

List of usage examples for java.util.concurrent CompletableFuture supplyAsync

Introduction

In this page you can find the example usage for java.util.concurrent CompletableFuture supplyAsync.

Prototype

public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier) 

Source Link

Document

Returns a new CompletableFuture that is asynchronously completed by a task running in the ForkJoinPool#commonPool() with the value obtained by calling the given Supplier.

Usage

From source file:ru.histone.v2.evaluator.Evaluator.java

private CompletableFuture<EvalNode> processRegExp(ExpAstNode node) {
    return CompletableFuture.supplyAsync(() -> {
        final LongAstNode flagsNumNode = node.getNode(1);
        final long flagsNum = flagsNumNode.getValue();

        int flags = 0;
        if ((flagsNum & AstRegexType.RE_IGNORECASE.getId()) != 0) {
            flags |= Pattern.CASE_INSENSITIVE;
        }/*from   ww w. j a va 2s  .  c  o m*/
        if ((flagsNum & AstRegexType.RE_MULTILINE.getId()) != 0) {
            flags |= Pattern.MULTILINE;
        }

        final boolean isGlobal = (flagsNum & AstRegexType.RE_GLOBAL.getId()) != 0;
        final StringAstNode expNode = node.getNode(0);
        final String exp = expNode.getValue();
        final Pattern pattern = Pattern.compile(exp, flags);
        return new RegexEvalNode(new HistoneRegex(isGlobal, pattern));
    });
}