|
|
|
@ -17,8 +17,8 @@ namespace pEp {
|
|
|
|
|
|
|
|
|
|
SYNC_EVENT _retrieve_next_sync_event(void *management, unsigned threshold);
|
|
|
|
|
|
|
|
|
|
std::exception_ptr _ex;
|
|
|
|
|
bool lpa_register_done = false;
|
|
|
|
|
static std::exception_ptr _ex;
|
|
|
|
|
static bool register_done = false;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
try {
|
|
|
|
|
throw_status(status);
|
|
|
|
|
lpa_register_done = true;
|
|
|
|
|
register_done = true;
|
|
|
|
|
}
|
|
|
|
|
catch (...) {
|
|
|
|
|
_ex = std::current_exception();
|
|
|
|
|
lpa_register_done = true;
|
|
|
|
|
register_done = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -69,19 +69,15 @@ namespace pEp {
|
|
|
|
|
|
|
|
|
|
session();
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> lock(m);
|
|
|
|
|
|
|
|
|
|
if (!_sync_thread) {
|
|
|
|
|
lpa_register_done = false;
|
|
|
|
|
_sync_thread = new std::thread(sync_thread<T>, obj, _startup, _shutdown);
|
|
|
|
|
while (!lpa_register_done)
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
|
|
|
|
|
|
|
|
if (_ex) {
|
|
|
|
|
_sync_thread = nullptr;
|
|
|
|
|
std::rethrow_exception(_ex);
|
|
|
|
|
}
|
|
|
|
|
if (!_sync_thread) {
|
|
|
|
|
register_done = false;
|
|
|
|
|
_sync_thread = new std::thread(sync_thread<T>, obj, _startup, _shutdown);
|
|
|
|
|
while (!register_done)
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
|
|
|
|
|
|
|
|
if (_ex) {
|
|
|
|
|
_sync_thread = nullptr;
|
|
|
|
|
std::rethrow_exception(_ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|