3 ms·
I am assuming that the global queue is written in a way that makes enqueuing and dequeueing an atomic operation that cannot cause a control switch. This code wi
by simula67 12y ago
I am assuming that the global queue is written in a way that makes enqueuing and dequeueing an atomic operation that cannot cause a control switch. This code will ensure that re-entrance is unpermitted only during the relatively short time it takes to enqueue or dequeue an element as opposed to making the whole signal handler code non-reentrable.
- benmmurphy 12y agoI think it works because signal handling in ruby is implemented within its own queue. It looks like when signals happen in ruby they are added to a buffer and then threads check this buffer when they are running. So threads will only run signals when it is compatible with the global interpreter lock to do so. So as you said this would make the enqueing/dequeuing atomic because they are protected by the GIL.