1
0
mirror of https://github.com/facebook/zstd.git synced 2025-08-07 06:23:00 +03:00

Fix memory usage issues.

This commit is contained in:
Nick Terrell
2016-09-02 20:11:22 -07:00
parent 6e1b95b01c
commit 9622fe499d
4 changed files with 65 additions and 7 deletions

View File

@@ -99,6 +99,19 @@ class WorkQueue {
return true;
}
/**
* Sets the maximum queue size. If `maxSize == 0` then it is unbounded.
*
* @param maxSize The new maximum queue size.
*/
void setMaxSize(std::size_t maxSize) {
{
std::lock_guard<std::mutex> lock(mutex_);
maxSize_ = maxSize;
}
writerCv_.notify_all();
}
/**
* Promise that `push()` won't be called again, so once the queue is empty
* there will never any more work.
@@ -149,6 +162,10 @@ class BufferWorkQueue {
return result;
}
void setMaxSize(std::size_t maxSize) {
queue_.setMaxSize(maxSize);
}
void finish() {
queue_.finish();
}