4 ms·
Thanks for the detailed reply. Does scheduling work via queues (channels they call they now right? :)) alleviate most of these issues, while sacrificing some e
by alexashka 8y ago
Thanks for the detailed reply.
Does scheduling work via queues (channels they call they now right? :)) alleviate most of these issues, while sacrificing some efficiency?
The scenarios you've described are brittle by design - I imagine better designs are out there?
- SamReidHughes 8y agoI don't know what exactly a queue or channel is as you mean it, so it could depend, but the short answer is if you can throw in real mutexes and won't risk deadlock then that's a big mitigation. A good way to improve all the scenarios I've mentioned is to return a future instead of calling a callback. Many of the problems basically go away, if you use futures for everything. There is still some danger of scenario 2 at the boundary between futures and other code. Some futures libraries in systems that have an event loop (like JavaScript, I've been told) always schedule futures' callbacks asynchronously partly for this reason. But others don't, partly because they're written not to depend on an event loop. A consequence is also better performance, but a risk of stack overflow.