Hi there, on line 206 in steal() you have moved the ->get() call into the CAS if, (as oppose to before like Figure 1. in the reference material). I believe this introduces a bug as:
- Thread A executes a
steal() and hangs just after successfully completing the CAS.
- A push occurs, from thread B, that overwrites the stolen item (due to buffer wrap around).
- A wakes up and retrieves the wrong item.
This could be fixed by moving the ->get() before the CAS branch but then a copy must be made for every steal, even the unsuccessful ones :(
Hi there, on line 206 in
steal()you have moved the->get()call into the CAS if, (as oppose to before like Figure 1. in the reference material). I believe this introduces a bug as:steal()and hangs just after successfully completing the CAS.This could be fixed by moving the
->get()before the CAS branch but then a copy must be made for every steal, even the unsuccessful ones :(