News for hackers. Stuff that matters.
Re:Even in Go, concurrency is still not easy by unscaled on Thursday September 03, 2020 @05:46AM (#24362367)
Custom stackless coroutine schedulers are also available in Kotlin.

Python also also allows you to customize the event loop, I think, but overriding AbstractEventLoop. A M:N implementation would probably be inefficient though because of the GIL.

Basically almost all stackless implementations I know allow for custom scheduling. The fact that some of them can't do M:N and are restricted to 1:N is just a limitation of dynamic programming languages. There is a global interpreter state which prevents you from using multiple OS threads efficiently. You either rely on GIL (CPython and Ruby MRI) or rely on just allow only one thread (Node, Lua).

So GP is right in that not _all_ async/await implementations will allow you to fully customize your threads but I think the main point here is that stackless coroutines are practically _a prerequisite_ for enabling custom scheduling (like C# et. al allow). You cannot have this custom scheduling with stackful coroutines, because that would require the scheduler to have access to low level memory management for controlling the stack.

I've never seen a language which allows that. I guess this could be doable on C++, but I really don't see the point, since it will require a lot more effort than the current stackless C++ coroutines.

Re:Even in Go, concurrency is still not easy by pjmlp on Thursday September 03, 2020 @06:09AM (#24362502)
That is my whole point, this is not doable with Go channels alone as primitive.
Re:Even in Go, concurrency is still not easy by gpderetta on Thursday September 03, 2020 @06:56AM (#24362744)
Yes, that's not a good primitive. You need some delimited form of call/cc.
Re:Even in Go, concurrency is still not easy by gpderetta on Thursday September 03, 2020 @06:55AM (#24362741)
> I've never seen a language which allows that.

It is not really hard. You can use the exact same scheduler you would use for stackless coroutines.

For example in C++ land you can use boost.asio to schedule both stackless coroutines and boost.fibers (or whatever have you). Boost.asio predates both and doesn't care.