+ if (head_node == tail_node) {
+ count = tail.load() - head.load();
+ } else {
+ count =
+ (head_node->values + (SYNC_QUEUE_BUFSIZE - 1)) - head.load();
+ for (node* n = head_node->next; n != tail_node; n = n->next)
+ count += SYNC_QUEUE_BUFSIZE;
+ count += tail.load() - tail_node->values;
+ }