jamesmunns / bbqueue

A SPSC, lockless, no_std, thread safe, queue, based on BipBuffers
Apache License 2.0
432 stars 51 forks source link

Load reserve once in GrantW::commit_inner #73

Closed dfreese closed 4 years ago

dfreese commented 4 years ago

This is testing my own understanding of how this is working. I was looking at porting a variation of this to C++, when I noticed that the return value of reserve in GrantW::commit_inner is updated in fetch_sub, but the return value of the fetch_sub is not used, forcing another load. This seemed like it could cause problems if the value was updated between the fetch_sub and the load.

dfreese commented 4 years ago

Looking at this further, I realize that reserve is owned by the writer, so this isn't actually an issue. I'm not sure if this is any faster either, so I'll close this unless there's a good way to determine if it would actually help. Sorry for the noise!