/// <summary> /// Creates a <see cref="IFuture{T}"/> which has an exception set /// immediately upon construction. /// <c>true</c>. /// </summary> /// <param name="exception">The exception that the returned future shoud /// hold.</param> /// <returns>A <see cref="IFuture{T}"/> whose has failed with exception /// <paramref name="exception"/> and is in the completed state.</returns> /// <remarks> /// The returned <see cref="IFuture{T}"/> object can't be cancelled or /// and its <see cref="IFuture{T}.IsCompleted"/> property always returns /// <c>true</c>. /// <para> /// Calling "get(...)" will immediately throw the provided exception /// wrapped in an <see cref="ExecutionException"/>. /// </para> /// </remarks> public static IFuture <T> ImmediateFailedFuture <T>(Exception exception) { if (exception == null) { throw new ArgumentNullException("exception"); } SettableFuture <T> future = new SettableFuture <T>(); future.SetException(exception, true); return(future); }