Skip to content

Commit

Permalink
fixing dequeue to decrement bytes for the buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
thesmart committed Dec 26, 2012
1 parent 8fb0727 commit ad4eeb5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/message_batch_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ MessageBatchStream.prototype.enQueue = function(message) {
this.countBytes += this.sizeOfMsg(message);
};

/**
* Dequeue a batch of items
* @return {Array}
*/
MessageBatchStream.prototype.deQueueBatch = function() {
var subBuffer = AccStream.prototype.deQueueBatch.call(this);
for (var i = 0; i < subBuffer.length; i++) {
var message = subBuffer[i];
this.countBytes -= this.sizeOfMsg(message);
}
this.countBytes = Math.max(this.countBytes, 0);
return subBuffer;
};

/**
* Get the size of a message Object
* @param {Object} message
Expand Down

0 comments on commit ad4eeb5

Please sign in to comment.