@@ -208,7 +208,8 @@ void Stream::pushToReadyQ(DcpResponse* resp)
208208{
209209 if (resp) {
210210 readyQ.push (resp);
211- readyQueueMemory += resp->getMessageSize ();
211+ readyQueueMemory.fetch_add (resp->getMessageSize (),
212+ memory_order_relaxed);
212213 }
213214}
214215
@@ -218,20 +219,20 @@ void Stream::popFromReadyQ(void)
218219 uint32_t respSize = readyQ.front ()->getMessageSize ();
219220 readyQ.pop ();
220221 /* Decrement the readyQ size */
221- if ((readyQueueMemory - respSize) <= readyQueueMemory) {
222- readyQueueMemory -= respSize;
222+ if (respSize <= readyQueueMemory. load (memory_order_relaxed) ) {
223+ readyQueueMemory. fetch_sub ( respSize, memory_order_relaxed) ;
223224 } else {
224225 LOG (EXTENSION_LOG_DEBUG, " readyQ size for stream %s (vb %d)"
225226 " underflow, likely wrong stat calculation! curr size: %llu;"
226- " new size: %d" , name_.c_str (), getVBucket (), readyQueueMemory,
227+ " new size: %d" , name_.c_str (), getVBucket (), readyQueueMemory. load () ,
227228 respSize);
228- readyQueueMemory = 0 ;
229+ readyQueueMemory. store ( 0 , memory_order_relaxed) ;
229230 }
230231 }
231232}
232233
233234uint64_t Stream::getReadyQueueMemory () {
234- return readyQueueMemory;
235+ return readyQueueMemory. load (memory_order_relaxed) ;
235236}
236237
237238const char * Stream::stateName (stream_state_t st) const {
0 commit comments