6 ms·
> Knowing if a function will yield the thread is actually extremely relevant knowledge you want available. When is this relevant beyond pleasing the compiler/r
by valcron1000 11mo ago
> Knowing if a function will yield the thread is actually extremely relevant knowledge you want available.
When is this relevant beyond pleasing the compiler/runtime? I work in C# and JS and I could not care less. Give me proper green threads and don't bother with async.
- jayd16 11mo agoKnowing when execution will yield is useful when you want to hold onto a thread. If you run your GUI related async tasks on the GUI thread you don't have to worry about locks or multi threaded data structures. Only a single GUI operation will happen at a time. If yields are implicit, you don't have enough control to really pull that off. Maybe it's possible but I haven't seen a popular green threaded UI framework that let's you run tasks in background threads implicitly. If I need to call a bunch of code to explicitly parcel background work, that just ends up being async/await with less sugar.