Hexagen: True coroutines for Swift
github.com
github.com
https://gist.github.com/Sidnicious/8e57892b14629c5ec740
I understand the main benefits of coroutines as:
- Cheap creation
- Cheap context switching
- Predictable context switching
…and I don't know the performance characteristics of Grand Central Dispatch. Could someone who's more familiar with GCD explain why using it for this kind of concurrency is an okay/bad idea and how it compares to coroutines?
(FWIW I'm a huge fan of hacking async semantics into languages and made a thing like this for C++: https://github.com/Sidnicious/team)
You can test this yourself. Experimentally, the limit on OS X 10.10.2 (with the global background queue) is 64 blocked threads. I used the following program to see that: https://gist.github.com/kballard/ff3640e08f2238875680