mirror of
https://github.com/eclipse-paho/paho.mqtt.cpp.git
synced 2025-09-15 12:58:39 +08:00
#556 fix potential deadlock in thread_queue on capacity increase
This commit is contained in:
parent
49278fae82
commit
5e647ce961
@ -152,11 +152,13 @@ public:
|
||||
* 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
|
||||
* a sufficient number of items are removed from the queue.
|
||||
*/
|
||||
void capacity(size_type cap) {
|
||||
guard g{lock_};
|
||||
cap_ = cap;
|
||||
cap_ = std::max<size_type>(cap, 1);
|
||||
if (cap_ > que_.size())
|
||||
notFullCond_.notify_all();
|
||||
}
|
||||
/**
|
||||
* Gets the number of items in the queue.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user