Browse Source

...

ENGINE-524
Volker Birk 4 years ago
parent
commit
7421773c1e
6 changed files with 21 additions and 15 deletions
  1. +3
    -2
      .hgignore
  2. +2
    -2
      setup.py
  3. +3
    -3
      src/adapter.cc
  4. +10
    -6
      src/adapter.hh
  5. +1
    -0
      src/pEpmodule.cc
  6. +2
    -2
      src/user_interface.cc

+ 3
- 2
.hgignore View File

@ -1,8 +1,9 @@
syntax: glob
*.swp
*.o
*.so
ws
tags
.DS_Store
pEp.egg-info
dist
build

+ 2
- 2
setup.py View File

@ -62,9 +62,9 @@ module_pEp = Extension('pEp',
setup(
name='p≡p Python adapter',
name='pEp',
version='2.0',
description='Provides a Python module giving access to p≡p engine',
description='p≡p for Python',
author="Volker Birk",
author_email="vb@pep-project.org",
ext_modules=[module_pEp,],


+ 3
- 3
src/adapter.cc View File

@ -18,7 +18,7 @@ namespace pEp {
PEP_SESSION Adapter::session(session_action action)
{
lock_guard<mutex> lock(mtx);
lock_guard<mutex> lock(mtx());
thread_local static PEP_SESSION _session = nullptr;
thread_local int booked = 0;
@ -56,7 +56,7 @@ namespace pEp {
PyObject *Adapter::ui_object(PyObject *value)
{
lock_guard<mutex> lock(mtx);
lock_guard<mutex> lock(mtx());
static PyObject *obj = nullptr;
if (value)
obj = value;
@ -80,7 +80,7 @@ namespace pEp {
}
try {
q.push_front(ev);
queue().push_front(ev);
}
catch (exception&) {
return 1;


+ 10
- 6
src/adapter.hh View File

@ -28,7 +28,11 @@ namespace pEp {
};
PEP_SESSION session(session_action action = none);
static ::utility::locked_queue< SYNC_EVENT > q;
static ::utility::locked_queue< SYNC_EVENT >& queue()
{
static ::utility::locked_queue< SYNC_EVENT > q;
return q;
}
protected:
static PyObject *ui_object(PyObject *value = nullptr);
@ -36,11 +40,11 @@ namespace pEp {
static int _inject_sync_event(SYNC_EVENT ev, void *management);
private:
static mutex mtx;
// non copyable
Adapter(const Adapter&) = delete;
Adapter& operator= (const Adapter&) = delete;
static mutex& mtx()
{
static mutex m;
return m;
}
friend class UserInterface_callback;
};


+ 1
- 0
src/pEpmodule.cc View File

@ -9,6 +9,7 @@
#include "basic_api.hh"
#include "message_api.hh"
#include "user_interface.hh"
#include "adapter.hh"
#include <mutex>


+ 2
- 2
src/user_interface.cc View File

@ -51,9 +51,9 @@ namespace pEp {
SYNC_EVENT UserInterface::retrieve_next_sync_event(void *management)
{
while (adapter.q.empty())
while (adapter.queue().empty())
nanosleep((const struct timespec[]){{0, 100000000L}}, NULL);
return adapter.q.pop_front();
return adapter.queue().pop_front();
}
void UserInterface_callback::notifyHandshake(


Loading…
Cancel
Save