diff --git a/native/cpp/CommonCpp/Tools/WorkerThread.cpp b/native/cpp/CommonCpp/Tools/WorkerThread.cpp index 6317527b2..02758baf1 100644 --- a/native/cpp/CommonCpp/Tools/WorkerThread.cpp +++ b/native/cpp/CommonCpp/Tools/WorkerThread.cpp @@ -1,42 +1,42 @@ #include "WorkerThread.h" #include "Logger.h" #include namespace comm { WorkerThread::WorkerThread(const std::string name) - : tasks(folly::MPMCQueue>(100)), name(name) { + : tasks(folly::MPMCQueue>(500)), name(name) { auto job = [this]() { while (true) { std::unique_ptr lastTask; this->tasks.blockingRead(lastTask); if (lastTask == nullptr) { break; } (*lastTask)(); } }; this->thread = std::make_unique(job); } void WorkerThread::scheduleTask(const taskType task) { if (!this->tasks.write(std::make_unique(std::move(task)))) { throw std::runtime_error( "Error scheduling task on the " + this->name + " worker thread"); } } WorkerThread::~WorkerThread() { this->tasks.blockingWrite(nullptr); try { this->thread->join(); } catch (const std::system_error &error) { std::ostringstream stringStream; stringStream << "Error occurred joining the " + this->name + " worker thread: " << error.what(); Logger::log(stringStream.str()); } } } // namespace comm