2 ms·
It is not just for io. If a system is better modelled with a set of indipendent execution flows exchaging messages (a simulation for example), then coroutines a
by gpderetta 8y ago
It is not just for io. If a system is better modelled with a set of indipendent execution flows exchaging messages (a simulation for example), then coroutines are perfect. Games often use coroutines to model game entities: it is not a coincidence that lua has excellent coroutine support.
- crimsonalucard 8y agoRight, except that's not what's happening in reality no matter how you model it. Having your code mimic the actual pathway of execution rather than the overhead of simulating parallelism is more efficient. Typically multithreading adds way more complexity and a whole new class of bugs to the code.