diff --git a/.hgignore b/.hgignore index 9b4c464..b081e1b 100644 --- a/.hgignore +++ b/.hgignore @@ -9,3 +9,5 @@ test_adapter lib local.conf build/ +# Default ignored files +.idea/ diff --git a/Adapter.cc b/Adapter.cc index cd213f9..579dd69 100644 --- a/Adapter.cc +++ b/Adapter.cc @@ -12,6 +12,7 @@ using namespace std; namespace pEp { void throw_status(PEP_STATUS status) { + pEpLog("called"); if (status == PEP_STATUS_OK) return; if (status >= 0x400 && status <= 0x4ff) @@ -28,7 +29,7 @@ namespace pEp { RuntimeError::RuntimeError(const std::string& _text, PEP_STATUS _status) : std::runtime_error(_text.c_str()), text(_text), status(_status) { - + pEpLog("called"); } namespace Adapter { @@ -36,18 +37,19 @@ namespace pEp { notifyHandshake_t _notifyHandshake = nullptr; std::thread *_sync_thread = nullptr; - ::utility::locked_queue< SYNC_EVENT, ::free_Sync_event > q; + ::utility::locked_queue< SYNC_EVENT, ::free_Sync_event > sync_q; std::mutex m; int _inject_sync_event(SYNC_EVENT ev, void *management) { + pEpLog("called"); try { if (ev == nullptr) { - q.clear(); - q.push_back(ev); + sync_q.clear(); + sync_q.push_back(ev); } else { - q.push_front(ev); + sync_q.push_front(ev); } } catch (exception&) { @@ -61,7 +63,7 @@ namespace pEp { delete _sync_thread; _sync_thread = nullptr; pEpLog("...thread joined"); - q.clear(); + sync_q.clear(); } else { //FATAL pEpLog("FATAL: sync thread not joinable/detached"); @@ -74,8 +76,9 @@ namespace pEp { // threshold: max waiting time in seconds SYNC_EVENT _retrieve_next_sync_event(void *management, unsigned threshold) { + pEpLog("called"); SYNC_EVENT syncEvent = nullptr; - const bool success = q.try_pop_front(syncEvent, std::chrono::seconds(threshold)); + const bool success = sync_q.try_pop_front(syncEvent, std::chrono::seconds(threshold)); if (!success) return new_sync_timeout_event(); @@ -85,6 +88,7 @@ namespace pEp { bool on_sync_thread() { + pEpLog("called"); if (_sync_thread && _sync_thread->get_id() == this_thread::get_id()) return true; else @@ -93,6 +97,7 @@ namespace pEp { PEP_SESSION session(session_action action) { + pEpLog("called"); std::lock_guard lock(m); bool in_sync = on_sync_thread(); @@ -131,6 +136,7 @@ namespace pEp { bool is_sync_running() { + pEpLog("called"); return _sync_thread != nullptr; } } diff --git a/Adapter.hh b/Adapter.hh index d22b5cb..f17f984 100644 --- a/Adapter.hh +++ b/Adapter.hh @@ -7,14 +7,7 @@ #include #include #include - -// TODO: put into not yet existing libpEpAdapter_utils.h, to be across whole libpEpAdapter -#ifdef NDEBUG - #define pEpLog(msg) do{}while(0) -#else - #include - #define pEpLog(msg) do{std::cerr << __FILE__ << "::" << __FUNCTION__ << " - " << msg << '\n';} while(0) -#endif +#include "utils.hh" namespace pEp { diff --git a/Makefile b/Makefile index b8c723c..98d82c4 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ ifdef BUILD_CONFIG $(info ================================================) endif -.PHONY: all, lib, test, install, uninstall, clean +.PHONY: all lib test install uninstall clean SOURCE=$(wildcard *.cc) HEADERS=$(wildcard *.hh *.hxx) diff --git a/Makefile.conf b/Makefile.conf index bb95499..74f33b0 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -32,11 +32,11 @@ else CXXFLAGS+=-DNDEBUG=1 endif -######### Engine ######### +# Defaults ENGINE_LIB_PATH=$(HOME)/lib ENGINE_INC_PATH=$(HOME)/include -######### Overrides ######### +# Config File -include $(HERE)/local.conf # Add -L Prefixes to LIB/INC paths, diff --git a/utils.hh b/utils.hh new file mode 100644 index 0000000..ab328c1 --- /dev/null +++ b/utils.hh @@ -0,0 +1,9 @@ +#pragma once + + +#ifdef NDEBUG + #define pEpLog(msg) do{}while(0) +#else + #include + #define pEpLog(msg) do{std::cerr << __FILE__ << "::" << __FUNCTION__ << " - " << msg << '\n';} while(0) +#endif