Browse Source

startup() may throw RuntimeError

sync
Volker Birk 6 years ago
parent
commit
c25feca938
  1. 2
      Adapter.hh
  2. 12
      Adapter.hxx

2
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();

12
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<std::mutex> lock(m);
if (!_sync_thread)
_sync_thread = new std::thread(sync_thread<T>, obj, _startup, _shutdown);
if (!_sync_thread) {
try {
_sync_thread = new std::thread(sync_thread<T>, obj, _startup, _shutdown);
}
catch (RuntimeError& ex) {
_sync_thread = nullptr;
throw ex;
}
}
}
}
}

Loading…
Cancel
Save