Browse Source

_inject_sync_event: undo the renaming for now.

android-build
heck 4 years ago
parent
commit
9eb0b4c032
  1. 14
      src/Adapter.cc
  2. 2
      src/Adapter.hh
  3. 4
      src/Adapter.hxx

14
src/Adapter.cc

@ -47,7 +47,7 @@ namespace pEp {
::messageToSend_t _messageToSend = nullptr; ::messageToSend_t _messageToSend = nullptr;
::notifyHandshake_t _notifyHandshake = nullptr; ::notifyHandshake_t _notifyHandshake = nullptr;
bool _adapter_manages_sync_thread = false; bool _adapter_manages_sync_thread = false;
::inject_sync_event_t _inject_action = _queue_sync_event; ::inject_sync_event_t _inject_action = _inject_sync_event;
std::thread _sync_thread; std::thread _sync_thread;
::utility::locked_queue<SYNC_EVENT, ::free_Sync_event> sync_evt_q; ::utility::locked_queue<SYNC_EVENT, ::free_Sync_event> sync_evt_q;
std::mutex mut; std::mutex mut;
@ -78,7 +78,7 @@ namespace pEp {
// std::lock_guard<mutex> lock(mut); // std::lock_guard<mutex> lock(mut);
_sync_mode = mode; _sync_mode = mode;
if (_sync_mode == SyncModes::Sync) { if (_sync_mode == SyncModes::Sync) {
// init sesssion with inject_sync = process // init session with inject_sync = process
// stop sync // stop sync
session(release); session(release);
_inject_action = _process_sync_event; _inject_action = _process_sync_event;
@ -94,7 +94,7 @@ namespace pEp {
// init session with inject_sync = queue // init session with inject_sync = queue
// start sync thread // start sync thread
session(release); session(release);
_inject_action = _queue_sync_event; _inject_action = _inject_sync_event;
session(init); session(init);
if(!_adapter_manages_sync_thread) { if(!_adapter_manages_sync_thread) {
if (!is_sync_running()) { if (!is_sync_running()) {
@ -113,7 +113,7 @@ namespace pEp {
// Adapter needs to shutdown sync thread // Adapter needs to shutdown sync thread
} }
session(release); session(release);
_inject_action = _queue_sync_event; _inject_action = _inject_sync_event;
session(init); session(init);
} }
return; return;
@ -130,8 +130,8 @@ namespace pEp {
} }
} }
// private // public (json adapter needs it, but should use Session mgmt from libpEpAdapter eventually)
int _queue_sync_event(::SYNC_EVENT ev, void *management) int _inject_sync_event(::SYNC_EVENT ev, void *management)
{ {
try { try {
if (ev == nullptr) { if (ev == nullptr) {
@ -207,7 +207,7 @@ namespace pEp {
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");
_queue_sync_event(nullptr, nullptr); _inject_sync_event(nullptr, nullptr);
_sync_thread.join(); _sync_thread.join();
} }
} }

2
src/Adapter.hh

@ -42,7 +42,7 @@ namespace pEp {
void set_sync_mode(SyncModes mode); void set_sync_mode(SyncModes mode);
int _queue_sync_event(::SYNC_EVENT ev, void *management); int _inject_sync_event(::SYNC_EVENT ev, void *management);
int _process_sync_event(::SYNC_EVENT ev, void *management); int _process_sync_event(::SYNC_EVENT ev, void *management);
::PEP_STATUS _ensure_passphrase(::PEP_SESSION session, const char *fpr); ::PEP_STATUS _ensure_passphrase(::PEP_SESSION session, const char *fpr);

4
src/Adapter.hxx

@ -97,7 +97,7 @@ namespace pEp {
/* /*
* Sync Thread Startup * Sync Thread Startup
* 1. ensure session for the main thread (registers: messageToSend, _queue_sync_event, _ensure_passphrase) * 1. ensure session for the main thread (registers: messageToSend, _inject_sync_event, _ensure_passphrase)
* 2. Start the sync thread * 2. Start the sync thread
* 3. Defer execution until sync thread register_sync_callbacks() has returned * 3. Defer execution until sync thread register_sync_callbacks() has returned
* 4. Throw pending exception from the sync thread * 4. Throw pending exception from the sync thread
@ -120,7 +120,7 @@ namespace pEp {
_notifyHandshake = notifyHandshake; _notifyHandshake = notifyHandshake;
} }
pEpLog("ensure session for the main thread"); pEpLog("ensure session for the main thread");
// 1. re-initialize session for the main thread (registers: messageToSend, _queue_sync_event, _ensure_passphrase) // 1. re-initialize session for the main thread (registers: messageToSend, _inject_sync_event, _ensure_passphrase)
session(release); session(release);
session(init); session(init);

Loading…
Cancel
Save