On 14/01/15 08:28 -0500, Rafael Schloming wrote:
Hi Everyone,

I've been doing some work on a C reactor API for proton that is intended to fit
both alongside and underneath what gordon has been doing in pure python. I have
several goals with this work.

 - Simplify/enable a reactive style of programming in C that is similar to what
gordon has built out in pure python.

 - Provide a C API that translates well into the python/ruby/etc bindings, so
that sophisticated handlers can be written once in C rather than being
duplicated in each scripting language.

 - Preserve the extensibility/flexibility that comes with being able to define
custom handlers in the bindings, so python/ruby/etc handlers can intermix well
with C handlers.

Is the goal to be able to use swig here?

My question is based on the fact that swig is not as smart as it
should be when it comes to managing references and memory on the
python side. I believe some bugs were found in qpid-proton because of
this and I've hit this same issue in other projects.

When it comes to create python bindings for C code, I normally prefer
to use cffi[0] which is more reliable, the code bloat is less and it
gives you, in my opinion, more control over the C objects.

Other than this, I'm happy to see this happening!
Great work,
Flavio

[0] https://cffi.readthedocs.org/en/release-0.8/


 - Provide a C API that translates well into javascript via emscripten. In some
ways this is similar to the above goals with the other language bindings,
however I mention it separately because there are additional memory management
constraints for javascript since it has no finalizers.

I believe I've made significant progress towards most of these goals, although
there is still plenty of work left to do. I'd like to share a few examples both
to illustrate where I am with this and to solicit feedback and/or help.

Let me say up front that these examples aren't intended to be "hello world"
type examples. The focus of this work has really been on the reactor/handler/
event-dispatch infrastructure, and so the example I've chosen is really
intended to illustrate key aspects of how this works. To do that I've built an
example that sets up a recurring task, a server, and a client, all within the
same process and then sends a number of messages to itself.

I've included the same example twice, once written in C and once written in the
python binding of the C API. Please have a look and let me know what you think.

--
@flaper87
Flavio Percoco

Attachment: pgpV_38SV6YcQ.pgp
Description: PGP signature

Reply via email to