Created
February 4, 2022 09:25
-
-
Save rueian/93aa872bf531f42f53ee35af5f07d349 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (r *ring) EnqueueRequest(req request) response { | |
| s := &r.slots[atomic.AddUint64(&r.write, 1)&1023] | |
| for atomic.CompareAndSwapUint32(&s.mark, 0, 1) { | |
| runtime.Gosched() | |
| } | |
| s.req = req | |
| atomic.StoreUint32(&s.mark, 2) | |
| return <-s.ch | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment