3 ms·
Desktop operating systems all have application event loops that run within a single thread because the OS thread scheduler is not the same thing. If you just wa
by pavlov 3y ago
Desktop operating systems all have application event loops that run within a single thread because the OS thread scheduler is not the same thing. If you just want an event loop, trying to use threads instead for everything will often end up in tears due to concurrent data access issues.
- flohofwoe 3y agoAn async/await runtime doesn't necessarily need to run everything on the same thread though (that's really just a Javascript runtime restriction), instead it could use a thread pool. In this case, the same concurrent data issues would apply.
- gloryjulio 3y agoYes, basically golang model
- mpweiher 3y agoUse one or more service threads to do most work off the UI thread.
- pavlov 3y agoYes, sure. Operating systems nowadays provide useful thread pool runtimes for this purpose, like Apple’s GCD. In no way does it mean that you don’t need an event loop because threads exist, as was the contention here.
- mpweiher 3y ago1. You don't need either thread pools or GCD for this. GCD generally makes things worse. 2. It absolutely does mean you don't need the main thread event loop for non UI-events.