1
0
Fork 0
mirror of https://gitlab.com/niansa/commoncpp.git synced 2025-03-06 20:48:30 +01:00

Pooled thread: Added exception handler

This commit is contained in:
niansa 2023-06-10 16:49:10 +02:00
parent dea0a97047
commit 0e34d64040

View file

@ -1,5 +1,8 @@
#include "pooled_thread.hpp"
#include <exception>
#include <iostream>
namespace commoncpp {
@ -16,7 +19,11 @@ void PooledThread::main_loop() {
// Unlock queue
L.unlock();
// Call start function
e();
try {
e();
} catch (const std::exception& e) {
std::cerr << "Warning: Exception in pooled thread " << this << ": " << e.what() << std::endl;
}
// Lock queue
L.lock();
}