Skip to content

Fix await/asDeferred for MinimalState implementations #2457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 25, 2020

Conversation

elizarov
Copy link
Contributor

Fixes #2456

@elizarov elizarov requested a review from qwwdfsad December 18, 2020 09:29
@elizarov elizarov requested a review from qwwdfsad December 24, 2020 15:56
Copy link
Collaborator

@qwwdfsad qwwdfsad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix 👍

try {
@Suppress("UNCHECKED_CAST")
return get() as T
@Suppress("UNCHECKED_CAST", "BlockingMethodInNonBlockingContext")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// mayInterruptIfRunning is not used
(this as? CompletableFuture<T>)?.cancel(false)
consumer.cont = null // shall clear reference to continuation to aid GC
if (cont.isActive) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of optimizations that work 0.01% of the time (when future completes after isDone check but after whenComplete): hard to test and reason about.
I may be too opinionated here tho

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. It is indeed not needed anymore, where we (again) have fast-path via future.isDone here.

@elizarov elizarov merged commit 3aba905 into develop Dec 25, 2020
@elizarov elizarov deleted the minimal-stage-fix branch December 25, 2020 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants