Volker Birk 7 years ago
parent
commit
7421773c1e
  1. 5
      .hgignore
  2. 4
      setup.py
  3. 6
      src/adapter.cc
  4. 16
      src/adapter.hh
  5. 1
      src/pEpmodule.cc
  6. 4
      src/user_interface.cc

5
.hgignore

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

4
setup.py

@ -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,],

6
src/adapter.cc

@ -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;

16
src/adapter.hh

@ -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
src/pEpmodule.cc

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

4
src/user_interface.cc

@ -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