Skip to content

Rework Dispatchers.Unconfined to use thread-local event loop #704

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

Closed
qwwdfsad opened this issue Oct 15, 2018 · 0 comments
Closed

Rework Dispatchers.Unconfined to use thread-local event loop #704

qwwdfsad opened this issue Oct 15, 2018 · 0 comments

Comments

@qwwdfsad
Copy link
Member

qwwdfsad commented Oct 15, 2018

User's feedback (and the current state of K/N memory model) shows that Dispatchers.Unconfined is widely used (e.g. see #351) and some users treat it as a default dispatcher in their applications.

While there is nothing broken in "execute my coroutine in current thread" behaviour and it is generally useful, Dispatcher.Unconfined has a serious flaw, it is prone to nondeterministic StackOverflowError which is usually hard or impossible to encounter in unit tests.

We can emulate simple thread-local event loop in Unconined implementation.
It still will serve its purpose of being a bridge between Java'ish and coroutine worlds (where runBlocking is not suitable of course), but now it will not lead to SOE and could eventually leave its experimental status.

This change is breaking because it will change the order coroutines are executed in Unconfined dispatcher

@qwwdfsad qwwdfsad changed the title Unroll stack in unconfined dispatcher Unroll stack in Unconfined dispatcher Oct 15, 2018
@qwwdfsad qwwdfsad changed the title Unroll stack in Unconfined dispatcher Rework Dispatchers.Unconfined to use thread-local event loop Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant