Browse Source

Merge branch 'master' into Release_2.1

Release_2.1
heck 4 years ago
parent
commit
3dd36d3c5e
  1. 8
      src/Adapter.cc
  2. 5
      src/Adapter.hh
  3. 6
      src/pEpLog.cc
  4. 17
      src/pEpLog.hh

8
src/Adapter.cc

@ -201,13 +201,19 @@ namespace pEp {
return _session.get(); return _session.get();
} }
// public
void inject_sync_shutdown() {
pEpLog("called");
_inject_sync_event(nullptr, nullptr);
}
// public // public
void shutdown() void shutdown()
{ {
pEpLog("called"); pEpLog("called");
if (_sync_thread.joinable()) { if (_sync_thread.joinable()) {
pEpLog("sync_is_running - injecting null event"); pEpLog("sync_is_running - injecting null event");
_inject_sync_event(nullptr, nullptr); inject_sync_shutdown();
_sync_thread.join(); _sync_thread.join();
} }
} }

5
src/Adapter.hh

@ -77,6 +77,11 @@ namespace pEp {
extern thread_local Session session; extern thread_local Session session;
// only injects a NULL event into sync_event_queue
// Use this if adapter_manages_sync_thread
// Inject first, then join your thread.
void inject_sync_shutdown();
// injects a NULL event into sync_event_queue to denote sync thread to // injects a NULL event into sync_event_queue to denote sync thread to
// shutdown, and joins & removes the sync thread // shutdown, and joins & removes the sync thread
void shutdown(); void shutdown();

6
src/pEpLog.cc

@ -7,6 +7,10 @@
#include <mutex> #include <mutex>
#include <atomic> #include <atomic>
#ifdef ANDROID
#include <android/log.h>
#endif
namespace pEp { namespace pEp {
namespace Adapter { namespace Adapter {
@ -14,7 +18,7 @@ namespace pEp {
std::mutex mtx; std::mutex mtx;
std::atomic_bool is_enabled{false}; std::atomic_bool is_enabled{ false };
void set_enabled(bool enabled) void set_enabled(bool enabled)
{ {

17
src/pEpLog.hh

@ -6,10 +6,6 @@
#include <sstream> #include <sstream>
#include <thread> #include <thread>
#ifdef ANDROID
#include <android/log.h>
#endif
// pEpLog // pEpLog
// ====== // ======
// a "to be kept ultra small and simple" logging unit. // a "to be kept ultra small and simple" logging unit.
@ -36,12 +32,13 @@
do { \ do { \
} while (0) } while (0)
#else #else
#define pEpLog(msg) \ #define pEpLog(msg) \
do { \ do { \
std::stringstream msg_ss; \ std::stringstream msg_ss; \
msg_ss << std::this_thread::get_id() << " - " << __FILE__ << "::" << __FUNCTION__ << " - " << msg; \ msg_ss << std::this_thread::get_id() << " - " << __FILE__ << "::" << __FUNCTION__ \
pEp::Adapter::pEpLog::log(msg_ss.str()); \ << " - " << msg; \
} while(0) pEp::Adapter::pEpLog::log(msg_ss.str()); \
} while (0)
#endif // NDEBUG #endif // NDEBUG
namespace pEp { namespace pEp {

Loading…
Cancel
Save