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

hudson.util.Futures Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 *
 * Copyright (c) 2004-2009 Oracle Corporation.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * 
 *    Kohsuke Kawaguchi
 *
 *
 *******************************************************************************/ 

package hudson.util;

import hudson.remoting.Future;

import java.util.concurrent.TimeUnit;

/**
 * Various {@link Future} implementations.
 *
 * @author Kohsuke Kawaguchi
 */
public class Futures {

    /**
     * Creates a {@link Future} instance that already has its value
     * pre-computed.
     */
    public static  Future precomputed(final T value) {
        return new Future() {
            public boolean cancel(boolean mayInterruptIfRunning) {
                return false;
            }

            public boolean isCancelled() {
                return false;
            }

            public boolean isDone() {
                return true;
            }

            public T get() {
                return value;
            }

            public T get(long timeout, TimeUnit unit) {
                return value;
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy