diff --git a/Adapter.hh b/Adapter.hh index 745a457..907f8f1 100644 --- a/Adapter.hh +++ b/Adapter.hh @@ -29,7 +29,7 @@ namespace pEp { T *obj = nullptr, std::function< void (T *) > _startup = nullptr, std::function< void (T *) > _shutdown = nullptr - ); + ) throw (RuntimeError); // returns 'true' when called from the "sync" thread, 'false' otherwise. bool on_sync_thread(); diff --git a/Adapter.hxx b/Adapter.hxx index fb6e51c..8e783da 100644 --- a/Adapter.hxx +++ b/Adapter.hxx @@ -47,6 +47,7 @@ namespace pEp { function< void(T *) > _startup, function< void(T *) > _shutdown ) + throw (RuntimeError) { if (messageToSend) _messageToSend = messageToSend; @@ -59,8 +60,15 @@ namespace pEp { { std::lock_guard lock(m); - if (!_sync_thread) - _sync_thread = new std::thread(sync_thread, obj, _startup, _shutdown); + if (!_sync_thread) { + try { + _sync_thread = new std::thread(sync_thread, obj, _startup, _shutdown); + } + catch (RuntimeError& ex) { + _sync_thread = nullptr; + throw ex; + } + } } } }