Hi Alex
Make sure it is power of 2 size.
--Hi everybody,I'm having a bit of trouble figuring out ck_ring. I have a 92-element ring (which is a power of 2), and I can't enqueue more than 3 items before the following condition fails–http://imgur.com/BJn01Kf.pngMy guess was that this statement was meant to block enqueues when the buffer gets full. I don't understand how this ((delta & mask) == (consumer & mask)) statement is supposed to achieve that. Here's the result of a little Python test I came up with, where $mask is shown, $consumer is 0, and $delta is 0 to $mask –$mask: 91
((4 & 91) == (0 & 91)) == True
(0 == 0) == True
((32 & 91) == (0 & 91)) == True
(0 == 0) == True
((36 & 91) == (0 & 91)) == True
(0 == 0) == True
$mask: 92
((1 & 92) == (0 & 92)) == True
(0 == 0) == True
((2 & 92) == (0 & 92)) == True
(0 == 0) == True
((3 & 92) == (0 & 92)) == True
(0 == 0) == True
((32 & 92) == (0 & 92)) == True
(0 == 0) == True
((33 & 92) == (0 & 92)) == True
(0 == 0) == True
((34 & 92) == (0 & 92)) == True
(0 == 0) == True
((35 & 92) == (0 & 92)) == True
(0 == 0) == TrueI sometimes typo and transpose bitwise-and & with modulus %, which is how I accidentally realized that if I run the same test using this conditional instead, ((delta % mask) == (consumer % mask)), here's what I get:$mask: 91
((91 % 91) == (0 % 91)) == True
(0 == 0) == True
$mask: 92
((92 % 92) == (0 % 92)) == True
(0 == 0) == TrueIf I'm right, then changing this statement to modulus looks like the originally intended outcome. Have I found a bug? Or am I completely misusing ck_ring in some way?– Alex Forster
You received this message because you are subscribed to the Google Groups "Concurrency Kit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concurrencyki...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.