Skip to content
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

Support thread interrupting blocking functions (#1947) #1934

Closed
wants to merge 1 commit into from

Conversation

jxdabc
Copy link
Contributor

@jxdabc jxdabc commented Apr 22, 2020

This is implementation of issue #57 #1947 and non-intrusive variant of #1922

Signed-off-by: Trol jiaoxiaodong@xiaomi.com

@eggfly

This comment has been minimized.

@jxdabc jxdabc changed the title (non-intrusive) Implement optional thread interrupt on coroutine cancellation (#57) Support thread interrupting blocking functions (#1947) Apr 23, 2020
@jxdabc
Copy link
Contributor Author

jxdabc commented Apr 23, 2020

Amended as #1947:

@qwwdfsad
Copy link
Member

#1947 (comment)
Here is our final design.

Thanks a lot for your valuable contribution and moving this almost abandoned issue forward!
I realize there is a lot to do (along with a regular code-review that may take a bunch of iterations), so feel free to leave the rest of the changes on us if you don't have time to go this extra mile.

@jxdabc
Copy link
Contributor Author

jxdabc commented Apr 25, 2020

@qwwdfsad The design seems sweet. Especially as with avoid cross-block (launch...) misuse.

Thanks a lot for you to finally make coroutine together with interruption possible. That really helps a lot at least for some common Android patterns as I could see and make some people's work easy. I'd like to help complete this helpful progress.

@jxdabc
Copy link
Contributor Author

jxdabc commented Apr 25, 2020

@qwwdfsad

I added DSL restriction just now with a draft commit (didn't amend the previous one).

I found this DSL restriction may break existing code, as I commented as a code review comment for an example. Existing code may need change to use explicit reference to outer scope in this situation. Is that expected or is there something I missed?

Copy link
Member

@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.

Regarding DSL restrictions, it is actually my oversight and it seems to be impossible to achieve desired behaviour. One more task for refining DslMarker :)

Please just get rid of it (scope receiver, new interfaces, dsl annotations), let's fallback to the original plan.

kotlinx-coroutines-core/jvm/src/CancellationPoint.kt Outdated Show resolved Hide resolved
kotlinx-coroutines-core/jvm/src/CancellationPoint.kt Outdated Show resolved Hide resolved
kotlinx-coroutines-core/jvm/src/CancellationPoint.kt Outdated Show resolved Hide resolved
kotlinx-coroutines-core/jvm/src/CancellationPoint.kt Outdated Show resolved Hide resolved
kotlinx-coroutines-core/jvm/src/CancellationPoint.kt Outdated Show resolved Hide resolved
kotlinx-coroutines-core/jvm/src/CancellationPoint.kt Outdated Show resolved Hide resolved
kotlinx-coroutines-core/jvm/src/CancellationPoint.kt Outdated Show resolved Hide resolved
kotlinx-coroutines-core/jvm/src/CancellationPoint.kt Outdated Show resolved Hide resolved
kotlinx-coroutines-core/jvm/src/CancellationPoint.kt Outdated Show resolved Hide resolved
kotlinx-coroutines-core/jvm/src/CancellationPoint.kt Outdated Show resolved Hide resolved
This is implementation of issue Kotlin#1947

Signed-off-by: Trol <jiaoxiaodong@xiaomi.com>
@jxdabc
Copy link
Contributor Author

jxdabc commented Apr 28, 2020

@qwwdfsad
Thanks a lot for detailed advice. I amended the patch as to code review comments.

@jxdabc jxdabc requested a review from qwwdfsad April 28, 2020 12:45
@qwwdfsad qwwdfsad mentioned this pull request Apr 29, 2020
Copy link
Member

@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.

Thanks for the high-quality contribution!

I've slightly adjusted it (mostly documentation and the code style we prefer) and opened #1972.
Will merge it soon if you don't have any objections

@jxdabc
Copy link
Contributor Author

jxdabc commented Apr 29, 2020

Thanks. Glad to see that.

@qwwdfsad
Copy link
Member

Merged via #1972.
Thanks!

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.

None yet

3 participants