3 ms·
Here's the thing, if you can call functions that themselves can yield - you are in a shared memory multithreading model, where you can never guarantee for any f
by zzzcpan 9y ago
Here's the thing, if you can call functions that themselves can yield - you are in a shared memory multithreading model, where you can never guarantee for any function not to yield, so you have to use synchronization for that guarantee with all the same issues.
- aidenn0 9y agoIn a cooperative multi-threaded model you can only have data-races at function-call boundaries. For example: `x+=1` can never data-race.
- ngrilly 9y agoExcept if your programming language allows you to override the += operator.
- aidenn0 9y agoYou are proposing a situation where someone overrides += to specifically both call a blocking function and to not make it work correctly. I'm not saying it doesn't happen, but bad code is bad code regardless of your paradigm. Though I must admit I've not done cooperative multitasking in a language with operator overloading so I can't say whether or not this is a problem in practice.
- ngrilly 9y agoIn can happen for example in Python with gevent.