Oh, my GoD! Goroutines on D
Guillaume Piolat
firstname.name at spam.com
Fri Jan 3 00:17:27 UTC 2025
On Thursday, 2 January 2025 at 19:59:26 UTC, Jin wrote:
> If someone can tell me what could be wrong here, I would be
> very grateful.
https://github.com/nin-jin/go.d/blob/master/source/jin/go/queue.d#L67
A concurrent `put` and `popFront` will do nothing to avoid races
in `Queue`.
Individual access to _offset is atomic but its point of use in
both put and popFront is not.
Both functions look like this:
1. Atomic-read-offset
2. Anything can happen
3. Atomic-write-offset
If one function has completed 1) then other has completed 1+2+3
then you get a race.
Chaining two atomic things doesn't make the whole atomic, rather
classic mistake with mutual exclusion.
More information about the Digitalmars-d
mailing list