From 3e88d785c02954220d8481c540a5702c03e663f2 Mon Sep 17 00:00:00 2001 From: gabi Date: Sat, 25 Jan 2014 12:59:43 +0200 Subject: [PATCH] Minor comments --- include/c11log/details/blocking_queue.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/c11log/details/blocking_queue.h b/include/c11log/details/blocking_queue.h index ab3a2dae..0859b98b 100644 --- a/include/c11log/details/blocking_queue.h +++ b/include/c11log/details/blocking_queue.h @@ -35,7 +35,7 @@ public: } // Push copy of item into the back of the queue. - // If queue is full, block the calling thread util there is room or timeout have passed. + // If the queue is full, block the calling thread util there is room or timeout have passed. // Return: false on timeout, true on successful push. template bool push(const T& item, const std::chrono::duration& timeout) @@ -47,24 +47,24 @@ public: return false; } _q.push(item); - if (_q.size() == 1) + if (_q.size() <= 1) { - ul.unlock(); + ul.unlock(); //So the notified thread will have better chance to accuire the lock immediatly.. _item_pushed_cond.notify_one(); } return true; } // Push copy of item into the back of the queue. - // If queue is full, block the calling thread until there is room + // If the queue is full, block the calling thread until there is room. void push(const T& item) { while (!push(item, std::chrono::hours::max())); } - // Pop a copy of the front item in the queue into the given item ref - // If queue is empty, block the calling thread util there is item to pop or timeout have passed. - // Return: false on timeout , true on successful pop + // Pop a copy of the front item in the queue into the given item ref. + // If the queue is empty, block the calling thread util there is item to pop or timeout have passed. + // Return: false on timeout , true on successful pop/ template bool pop(T& item, const std::chrono::duration& timeout) { @@ -78,14 +78,14 @@ public: _q.pop(); if (_q.size() >= _max_size - 1) { - ul.unlock(); + ul.unlock(); //So the notified thread will have better chance to accuire the lock immediatly.. _item_popped_cond.notify_one(); } return true; } - // Pop a copy of the front item in the queue into the given item ref - // If queue is empty, block the calling thread util there is item to pop. + // Pop a copy of the front item in the queue into the given item ref. + // If the queue is empty, block the calling thread util there is item to pop. void pop(T& item) { while (!pop(item, std::chrono::hours::max()));