From 47d8cfbd97cebb50e2671f57b0ad50388b75c8cd Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Mon, 22 Oct 2018 17:54:15 +0200 Subject: [PATCH] simplify --- Adapter.cc | 14 +++++++++----- Adapter.hh | 4 ++-- Adapter.hxx | 10 ---------- libpEpAdapter/libpEpAdapter.vcxproj.filters | 6 +++--- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Adapter.cc b/Adapter.cc index 83c8f58..e477536 100644 --- a/Adapter.cc +++ b/Adapter.cc @@ -86,14 +86,18 @@ namespace pEp { return q.pop_front(); } - PEP_SESSION session(session_action action) + bool on_sync_thread() { - lock_guard lock(m); - bool in_sync; if (_sync_thread && _sync_thread->get_id() == this_thread::get_id()) - in_sync = true; + return true; else - in_sync = false; + return false; + } + + PEP_SESSION session(session_action action) + { + lock_guard lock(m); + bool in_sync = on_sync_thread(); thread_local static PEP_SESSION _session = nullptr; PEP_STATUS status = PEP_STATUS_OK; diff --git a/Adapter.hh b/Adapter.hh index e023740..4305314 100644 --- a/Adapter.hh +++ b/Adapter.hh @@ -24,13 +24,13 @@ namespace pEp { template void startup( messageToSend_t messageToSend, notifyHandshake_t notifyHandshake, - messageToSend_t messageToSend_sync = nullptr, - notifyHandshake_t notifyHandshake_sync = nullptr, T *obj = nullptr, function< void (T *) > _startup = nullptr, function< void (T *) > _shutdown = nullptr ); + bool on_sync_thread(); + enum session_action { init, release diff --git a/Adapter.hxx b/Adapter.hxx index 6eb83e7..903be07 100644 --- a/Adapter.hxx +++ b/Adapter.hxx @@ -8,8 +8,6 @@ namespace pEp { namespace Adapter { extern messageToSend_t _messageToSend; extern notifyHandshake_t _notifyHandshake; - extern messageToSend_t _messageToSend_sync; - extern notifyHandshake_t _notifyHandshake_sync; extern std::thread *_sync_thread; extern ::utility::locked_queue< SYNC_EVENT > q; @@ -38,8 +36,6 @@ namespace pEp { template< class T > void startup( messageToSend_t messageToSend, notifyHandshake_t notifyHandshake, - messageToSend_t messageToSend_sync, - notifyHandshake_t notifyHandshake_sync, T *obj, function< void(T *) > _startup, function< void(T *) > _shutdown @@ -51,12 +47,6 @@ namespace pEp { if (notifyHandshake) _notifyHandshake = notifyHandshake; - if (messageToSend_sync) - _messageToSend_sync = messageToSend_sync; - - if (notifyHandshake_sync) - _notifyHandshake_sync = notifyHandshake_sync; - session(); { diff --git a/libpEpAdapter/libpEpAdapter.vcxproj.filters b/libpEpAdapter/libpEpAdapter.vcxproj.filters index 3e8566b..3f1b2e6 100644 --- a/libpEpAdapter/libpEpAdapter.vcxproj.filters +++ b/libpEpAdapter/libpEpAdapter.vcxproj.filters @@ -26,14 +26,14 @@ Header Files - - Header Files - Header Files Header Files + + Source Files + \ No newline at end of file