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:
parent
dea0a97047
commit
0e34d64040
1 changed files with 8 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue