@@ -0,0 +1,1929 @@
+/*%0A * Copyright 2014 Timothy Brooks%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A */%0A%0Apackage net.uncontended.precipice.core.concurrent;%0A%0Aimport net.uncontended.precipice.core.Status;%0A%0Aimport java.util.concurrent.*;%0Aimport java.util.concurrent.atomic.AtomicReference;%0A%0Apublic class Eventual%3CT%3E implements Future%3CT%3E %7B%0A    private volatile T result;%0A    private Exception error;%0A    private final CountDownLatch latch = new CountDownLatch(1);%0A    private final AtomicReference%3CStatus%3E status = new AtomicReference%3C%3E(Status.PENDING);%0A%0A    @Override%0A    public T get() throws InterruptedException, ExecutionException %7B%0A        latch.await();%0A        return result;%0A    %7D%0A%0A    @Override%0A    public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException %7B%0A        if (latch.await(timeout, unit)) %7B%0A            if (result != null) %7B%0A                return result;%0A            %7D else %7B%0A                throw new ExecutionException(error);%0A            %7D%0A        %7D else %7B%0A            throw new TimeoutException();%0A        %7D%0A    %7D%0A%0A    @Override%0A    public boolean isDone() %7B%0A        return status.get() != Status.PENDING;%0A    %7D%0A%0A    @Override%0A    public boolean isCancelled() %7B%0A        return false;%0A    %7D%0A%0A    @Override%0A    public boolean cancel(boolean mayInterruptIfRunning) %7B%0A        throw new UnsupportedOperationException(%22Cancelling is not supported at this time%22);%0A    %7D%0A%7D%0A

Work on implementing new context for results