Wouldn't it be possible to implement all of the same semantics in pure Swift using a concurrent dispatch queue and some semaphores? I tried making a generator like the one in Hexagen:
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)