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 running coroutines on only one thread #9

Closed
Xudong-Huang opened this issue Dec 27, 2017 · 2 comments
Closed

support running coroutines on only one thread #9

Xudong-Huang opened this issue Dec 27, 2017 · 2 comments
Projects

Comments

@Xudong-Huang
Copy link
Owner

Xudong-Huang commented Dec 27, 2017

when user config MAY as following

may::config()::set_workers(1).set_io_workers(0);

MAY should running all the coroutines on a single thread. this would

  • help to avoid some tricky sync issue
  • allow library to access TLS since coroutines won't scheduled on other thread

This will NOT help the TLS issue. Let coroutines bound to a single thread is still not safe, e.g. coroutine A in the thread set a TLS into value A', and then another coroutine B is scheduled and it set the TLS into value B', after coroutine A rescheduled on this same thread, it will access a dirty value!

@Xudong-Huang Xudong-Huang added this to TODO in 0.2.0 Dec 27, 2017
@jedisct1
Copy link

So, there are no ways to use multiple threads and still use the standard library?

Or is there a way to have multiple May instances, one per thread?

@Xudong-Huang
Copy link
Owner Author

Xudong-Huang commented Dec 27, 2017

As far as users don't access TLS, of course we can have multiple thread scheduling, just like the echo server example.

But if users can't avoid using TLS, this is just a fallback way to let their code running normally.

Running multiple May instances is not considered in this library developing.

@Xudong-Huang Xudong-Huang moved this from TODO to Working in 0.2.0 Dec 28, 2017
Xudong-Huang added a commit that referenced this issue Dec 28, 2017
when may::config().set_io_worker(0)
only create one io worker thread and
all the coroutines are scheduled on worker thread
0.2.0 automation moved this from Working to Done Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
0.2.0
  
Done
Development

No branches or pull requests

2 participants