2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.common.util;
10 import java.util.concurrent.ExecutionException;
11 import java.util.concurrent.Future;
12 import java.util.concurrent.TimeUnit;
13 import java.util.concurrent.TimeoutException;
15 public class Futures {
20 public static <T> Future<T> immediateFuture(T result) {
21 return new ImmediateFuture<T>(result);
24 private static class ImmediateFuture<T> implements Future<T> {
26 private final T result;
28 public ImmediateFuture(T result) {
33 public boolean cancel(boolean mayInterruptIfRunning) {
38 public boolean isCancelled() {
43 public boolean isDone() {
48 public T get() throws InterruptedException, ExecutionException {
53 public T get(long timeout, TimeUnit unit) throws InterruptedException,
54 ExecutionException, TimeoutException {