Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Lazy future transforms are not called if the future is already completed #68

Open
alechenninger opened this issue Sep 10, 2016 · 2 comments

Comments

@alechenninger
Copy link
Contributor

Hasn't been a problem in practice by nature of their laziness, but this should be fixed. Shouldn't be hard.

@dcrissman
Copy link
Member

Is this because if (isDone()) return; happens first in the complete methods on LazyTransformingFuture and LazyTransformableFuture?

@alechenninger
Copy link
Contributor Author

No, if you look here:

@Override
public <V> TransformableFuture<V> transformSync(FutureTransform<U, V> futureTransform) {
    LazyTransformingFuture<U, V> future =
            new LazyTransformingFuture<>(futureTransform, completer);
    next.add(future);
    return future;
}

All this does is add it to the list of next futures to complete once we have a result.

What if we already have a result? The newly added futures will never be completed.

So in this method, we need to atomically check if the future is already completed, and in that case just complete the passed in future immediately, synchronously. Otherwise, add it to next.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants