Volker Birk 6 years ago
parent
commit
fad58207d7
  1. 16
      Adapter.hxx

16
Adapter.hxx

@ -17,8 +17,8 @@ namespace pEp {
SYNC_EVENT _retrieve_next_sync_event(void *management, unsigned threshold); SYNC_EVENT _retrieve_next_sync_event(void *management, unsigned threshold);
std::exception_ptr _ex; static std::exception_ptr _ex;
bool lpa_register_done = false; static bool register_done = false;
template< class T > void sync_thread(T *obj, function< void(T *) > _startup, function< void(T *) > _shutdown) template< class T > void sync_thread(T *obj, function< void(T *) > _startup, function< void(T *) > _shutdown)
{ {
@ -34,11 +34,11 @@ namespace pEp {
_notifyHandshake, _retrieve_next_sync_event); _notifyHandshake, _retrieve_next_sync_event);
try { try {
throw_status(status); throw_status(status);
lpa_register_done = true; register_done = true;
} }
catch (...) { catch (...) {
_ex = std::current_exception(); _ex = std::current_exception();
lpa_register_done = true; register_done = true;
return; return;
} }
} }
@ -69,13 +69,10 @@ namespace pEp {
session(); session();
{
std::lock_guard<std::mutex> lock(m);
if (!_sync_thread) { if (!_sync_thread) {
lpa_register_done = false; register_done = false;
_sync_thread = new std::thread(sync_thread<T>, obj, _startup, _shutdown); _sync_thread = new std::thread(sync_thread<T>, obj, _startup, _shutdown);
while (!lpa_register_done) while (!register_done)
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (_ex) { if (_ex) {
@ -86,4 +83,3 @@ namespace pEp {
} }
} }
} }
}

Loading…
Cancel
Save