diff --git a/pooled_thread.cpp b/pooled_thread.cpp index 7af54ee..4c7be1b 100644 --- a/pooled_thread.cpp +++ b/pooled_thread.cpp @@ -1,5 +1,8 @@ #include "pooled_thread.hpp" +#include +#include + 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(); }