We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent17ff3dc commitb11d17cCopy full SHA for b11d17c
include/mqtt/thread_queue.h
@@ -149,14 +149,18 @@ class thread_queue
149
return cap_;
150
}
151
/**
152
- * Sets the capacity of the queue.
153
- * Note that the capacity can be set to a value smaller than the current
154
- * size of the queue. In that event, all calls to put() will block until
155
-* a sufficient number
+ * Sets the capacity of the queue.
+ * Note that the capacity can be set to a value smaller than the current
+ * size of the queue. In that event, all calls to put() will block until
+* a sufficient number of items are removed from the queue.
156
*/
157
voidcapacity(size_type cap) {
158
- guard g{lock_};
159
- cap_ = cap;
+ unique_guardg(lock_);
+ cap_ = std::max<size_type>(cap,1);
160
+if(cap_ > que_.size()) {
161
+ g.unlock();
162
+ notFullCond_.notify_all();
163
+ }
164
165
166
* Gets the number of items in the queue.