2 ms·
> If the Store() caller goes to sleep between setting the type and storing the pointer, it causes every Goroutine that calls Load() to block. Where does this g
by yencabulator 4y ago
> If the Store() caller goes to sleep between setting the type and storing the pointer, it causes every Goroutine that calls Load() to block.
Where does this go to sleep: https://cs.opensource.google/go/go/+/refs/tags/go1.18.3:src/sync/atomic/value.go;l=47-83 https://cs.opensource.google/go/go/+/refs/tags/go1.18.3:src/...
It looks like a CAS busy loop with preemption disabled, to me.
- bumper_crop 4y agoMake sure to read between the lines. It only looks like a busy loop. Remember, the OS can pause and preempt your thread at any time. This is a real and likely event.
- mbnull 4y agoBy reading the lines and not between them, you could read these two lines: runtime_procPin() and runtime_procUnpin(). With explicit comments that these pause preemption.