From 546c6a89f09e113d57c503f9b63b967ee352eeb5 Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Thu, 4 Oct 2018 13:54:00 +0200 Subject: [PATCH] shutdown sync thread --- Adapter.cc | 5 +++++ Adapter.hh | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Adapter.cc b/Adapter.cc index 599edd9..0eeb386 100644 --- a/Adapter.cc +++ b/Adapter.cc @@ -78,6 +78,11 @@ namespace pEp { return _session; } + void Adapter::shutdown() + { + _inject_sync_event(nullptr, nullptr); + } + int Adapter::_inject_sync_event(SYNC_EVENT ev, void *management) { if (is_sync_thread(session())) { diff --git a/Adapter.hh b/Adapter.hh index ac9e7da..f5990e1 100644 --- a/Adapter.hh +++ b/Adapter.hh @@ -24,13 +24,9 @@ namespace pEp { init, release }; - static PEP_SESSION session(session_action action = init); - static ::utility::locked_queue< SYNC_EVENT >& queue() - { - static ::utility::locked_queue< SYNC_EVENT > q; - return q; - } + + void shutdown(); protected: static int _inject_sync_event(SYNC_EVENT ev, void *management); @@ -38,6 +34,12 @@ namespace pEp { static void sync_thread(void *obj); private: + static ::utility::locked_queue< SYNC_EVENT >& queue() + { + static ::utility::locked_queue< SYNC_EVENT > q; + return q; + } + static std::mutex& mtx() { static std::mutex m;