4 ms·
We use D fibers. When we want to cancel a fiber we throw an exception at it. When it next wakes up, it'll throw (much like sending an exception to a Python gene
by Peaker 9y ago
We use D fibers. When we want to cancel a fiber we throw an exception at it. When it next wakes up, it'll throw (much like sending an exception to a Python generator) -- which will make sure RAII cleanups take place and are not missed.
- aidenn0 9y agoGetting that right at the implementation level is quite hard; it also requires support at the OS level that isn't always there (e.g. interrupting a blocking system call).
- Peaker 9y agoThen avoid blocking system calls. When you can't, defer them to a thread that can be ignored.
- aidenn0 9y agoThat's a huge footgun in an environment where blocking calls are the default way to get almost anything done, and some calls cannot be made non-blocking.
- Peaker 9y agoTrue, but we don't have much trouble with it though. We don't directly call syscalls but use our own wrappers that take care of this for us.
- aidenn0 9y agoSorry for the late reply, but I just saw this reply. Can you share who "we" are? I'm always interested in new practical systems for concurrency.