@@ -3033,6 +3033,8 @@ void enableNMIWatchdog(const bool silent)
3033
3033
}
3034
3034
#endif
3035
3035
3036
+ constexpr const char * threadCreateErrorMessage = " This might be due to a too low limit for the number of threads per process. Try to increase it\n " ;
3037
+
3036
3038
class CoreTaskQueue
3037
3039
{
3038
3040
std::queue<std::packaged_task<void ()> > wQueue;
@@ -3043,28 +3045,38 @@ class CoreTaskQueue
3043
3045
CoreTaskQueue (CoreTaskQueue &) = delete ;
3044
3046
CoreTaskQueue & operator = (CoreTaskQueue &) = delete ;
3045
3047
public:
3046
- CoreTaskQueue (int32 core) :
3047
- worker ([=]() {
3048
+ CoreTaskQueue (int32 core)
3049
+ {
3048
3050
try {
3049
- TemporalThreadAffinity tempThreadAffinity (core, false );
3050
- std::unique_lock<std::mutex> lock (m);
3051
- while (1 ) {
3052
- while (wQueue.empty ()) {
3053
- condVar.wait (lock);
3051
+ worker = std::thread ([=]() {
3052
+ try {
3053
+ TemporalThreadAffinity tempThreadAffinity (core, false );
3054
+ std::unique_lock<std::mutex> lock (m);
3055
+ while (1 ) {
3056
+ while (wQueue.empty ()) {
3057
+ condVar.wait (lock);
3058
+ }
3059
+ while (!wQueue.empty ()) {
3060
+ wQueue.front ()();
3061
+ wQueue.pop ();
3062
+ }
3063
+ }
3054
3064
}
3055
- while (!wQueue. empty ()) {
3056
- wQueue. front ()();
3057
- wQueue. pop () ;
3065
+ catch ( const std::exception& e)
3066
+ {
3067
+ std::cerr << " PCM Error. Exception in CoreTaskQueue worker function: " << e. what () << " \n " ;
3058
3068
}
3059
- }
3069
+
3070
+ });
3060
3071
}
3061
- catch (const std::exception & e)
3072
+ catch (const std::exception& e)
3062
3073
{
3063
- std::cerr << " PCM Error. Exception in CoreTaskQueue worker function: " << e.what () << " \n " ;
3074
+ std::cerr << " PCM Error: caught exception " << e.what () << " while creating thread for core task queue " << core << " \n " <<
3075
+ threadCreateErrorMessage;
3076
+ throw ; // re-throw
3064
3077
}
3065
3078
3066
- })
3067
- {}
3079
+ }
3068
3080
void push (std::packaged_task<void ()> & task)
3069
3081
{
3070
3082
std::unique_lock<std::mutex> lock (m);
@@ -10939,15 +10951,23 @@ CounterWidthExtender::CounterWidthExtender(AbstractRawCounter * raw_counter_, ui
10939
10951
last_raw_value = (*raw_counter)();
10940
10952
extended_value = last_raw_value;
10941
10953
DBG (3 , " Initial Value " , extended_value);
10942
- UpdateThread = new std::thread (
10943
- [&]() {
10944
- while (1 )
10945
- {
10946
- MySleepMs (static_cast <int >(this ->watchdog_delay_ms ));
10947
- /* uint64 dummy = */ this ->read ();
10954
+ try {
10955
+ UpdateThread = new std::thread (
10956
+ [&]() {
10957
+ while (1 )
10958
+ {
10959
+ MySleepMs (static_cast <int >(this ->watchdog_delay_ms ));
10960
+ /* uint64 dummy = */ this ->read ();
10961
+ }
10948
10962
}
10963
+ );
10964
+ }
10965
+ catch (const std::exception& e)
10966
+ {
10967
+ std::cerr << " PCM Error: caught exception " << e.what () << " while creating thread for a CounterWidthExtender\n " <<
10968
+ threadCreateErrorMessage;
10969
+ throw ; // re-throw
10949
10970
}
10950
- );
10951
10971
}
10952
10972
CounterWidthExtender::~CounterWidthExtender ()
10953
10973
{
0 commit comments