All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.paralleluniverse.concurrent.util.AbstractCompletableExecutorService Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2013-2014, Parallel Universe Software Co. All rights reserved.
 * 
 * This program and the accompanying materials are dual-licensed under
 * either the terms of the Eclipse Public License v1.0 as published by
 * the Eclipse Foundation
 *  
 *   or (per the licensee's choosing)
 *  
 * under the terms of the GNU Lesser General Public License version 3.0
 * as published by the Free Software Foundation.
 */
package co.paralleluniverse.concurrent.util;

import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.RunnableFuture;

/**
 *
 * @author pron
 */
/**
 * Implements {@link CompletableExecutorService} execution methods atop the abstract {@link #execute}
 * method. More concretely, the {@code submit}, {@code invokeAny} and {@code invokeAll} methods
 * create {@link CompletableFutureTask} instances and pass them to {@link #execute}.
 *
 * 

In addition to {@link #execute}, subclasses must implement all methods related to shutdown and * termination. */ public abstract class AbstractCompletableExecutorService extends AbstractExecutorService implements CompletableExecutorService { @Override public CompletableFuture submit(Runnable task) { return (CompletableFuture) super.submit(task); } @Override public CompletableFuture submit(Runnable task, T result) { return (CompletableFuture) super.submit(task, result); } @Override public CompletableFuture submit(Callable task) { return (CompletableFuture) super.submit(task); } @Override protected RunnableFuture newTaskFor(final Runnable runnable, final T value) { return new CompletableFutureTask(new Callable() { @Override public T call() { runnable.run(); return value; } }); } @Override protected RunnableFuture newTaskFor(Callable callable) { return new CompletableFutureTask(callable); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy