Skip to content

Implement yield for unconfined dispatchers #750

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 2 commits into from
Oct 24, 2018
Merged

Conversation

qwwdfsad
Copy link
Member

Fixes #737

@qwwdfsad qwwdfsad requested a review from elizarov October 22, 2018 16:59
@@ -21,26 +21,33 @@ internal object UndispatchedEventLoop {
@JvmField
internal val threadLocalEventLoop = CommonThreadLocal { EventLoop() }

inline fun execute(continuation: DispatchedContinuation<*>, contState: Any?, mode: Int, block: () -> Unit) {
inline fun execute(continuation: DispatchedContinuation<*>, contState: Any?, mode: Int, doYield: Boolean = false, block: () -> Unit) : Boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Boolean result needs documentation on its meaning
  2. This line (with addition of doYield parameter) is too long.

@@ -227,6 +234,12 @@ internal interface DispatchedTask<in T> : Runnable {
}
}

internal fun DispatchedContinuation<Unit>.yield(): Boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Maybe rename to yieldUndispatched & document the meaning of boolean result. In the context of this particular file this extension function is hard to understand.
  2. Also refactor to idiomatic expression body, please, since this function does not do anything else but delegates to UndispatchedEventLoop.execute and this intent should be immediately clear.

Copy link
Contributor

@elizarov elizarov left a comment

Choose a reason for hiding this comment

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

LGTM!

@qwwdfsad qwwdfsad merged commit 0cf0283 into develop Oct 24, 2018
@qwwdfsad qwwdfsad deleted the yield-unconfined branch October 24, 2018 14:41
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