Browse Source

...

LPA-1
Volker Birk 4 years ago
parent
commit
d64b492c88
3 changed files with 21 additions and 11 deletions
  1. +9
    -7
      Adapter.cc
  2. +1
    -1
      Adapter.hh
  3. +11
    -3
      Makefile

+ 9
- 7
Adapter.cc View File

@ -27,7 +27,7 @@ namespace pEp {
messageToSend_t Adapter::_messageToSend = nullptr;
notifyHandshake_t Adapter::_notifyHandshake = nullptr;
std::thread *_sync_thread = nullptr;
std::thread *Adapter::_sync_thread = nullptr;
Adapter::Adapter(messageToSend_t messageToSend,
notifyHandshake_t notifyHandshake, void *obj)
@ -43,9 +43,9 @@ namespace pEp {
{
lock_guard<mutex> lock(mtx());
if (!_sync_thread) {
_sync_thread = new thread(sync_thread, obj);
_sync_thread->detach();
if (!Adapter::_sync_thread) {
Adapter::_sync_thread = new thread(sync_thread, obj);
Adapter::_sync_thread->detach();
}
}
}
@ -81,9 +81,11 @@ namespace pEp {
void Adapter::shutdown()
{
_inject_sync_event(nullptr, nullptr);
_sync_thread->join();
delete _sync_thread;
_sync_thread = nullptr;
if (Adapter::_sync_thread) {
Adapter::_sync_thread->join();
delete Adapter::_sync_thread;
Adapter::_sync_thread = nullptr;
}
}
int Adapter::_inject_sync_event(SYNC_EVENT ev, void *management)


+ 1
- 1
Adapter.hh View File

@ -30,7 +30,7 @@ namespace pEp {
session(release);
}
void shutdown();
static void shutdown();
protected:
static int _inject_sync_event(SYNC_EVENT ev, void *management);


+ 11
- 3
Makefile View File

@ -10,16 +10,24 @@ CXXFLAGS += -I$(HOME)/include -std=c++14
SOURCE=$(wildcard *.cc)
OBJECTS=$(subst .cc,.o,$(SOURCE))
WITHOUT_TESTS=$(patsubst test%.o,,$(OBJECTS))
all: $(TARGET)
%.o: %.cc %.hh
$(CXX) $(CXXFLAGS) -c $<
$(TARGET): $(OBJECTS)
$(TARGET): $(WITHOUT_TESTS)
ar -rc $@ $^
.PHONY: clean
.PHONY: clean test
clean:
rm -f $(TARGET) $(OBJECTS)
rm -f $(TARGET) $(OBJECTS) *.a test_adapter
test: test_adapter
./test_adapter
test_adapter: $(OBJECTS)
$(CXX) -o $@ -L$(HOME)/lib -lpEpEngine $(OBJECTS)

Loading…
Cancel
Save