After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 655282 - Add ZeroMQ bindings
Add ZeroMQ bindings
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings: Extra
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-07-25 18:20 UTC by Lewis Gunsch
Modified: 2014-06-12 22:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ZeroMQ bindings patch (5.32 KB, patch)
2011-07-25 18:20 UTC, Lewis Gunsch
needs-work Details | Review
ZeroMQ bindings patch (5.63 KB, patch)
2011-09-07 16:02 UTC, Lewis Gunsch
none Details | Review
Add ZeroMQ Bindings. (6.02 KB, patch)
2011-09-19 16:22 UTC, Lewis Gunsch
none Details | Review

Description Lewis Gunsch 2011-07-25 18:20:50 UTC
Created attachment 192630 [details] [review]
ZeroMQ bindings patch

I have attached a patch for ZeroMQ (libzmq) bindings. I also have 13 examples showing its use, which follow along with ZeroMQ's guide, to go into the wiki.

I am looking forward to comments, and if everything is OK for this to be merged into master. I would also propose myself as the maintainer for these bindings if they are accepted.
Comment 1 Evan Nemerson 2011-07-25 21:20:11 UTC
Review of attachment 192630 [details] [review]:

Instead of MSG and MSG.Msg, why not just put everything in a Message struct?

It looks great so far. There are a few issues I would like to address before pushing it into the Vala repository, though:

Why is the move method outside of the Msg struct?

Msg.data should probably be a uint8[] (and a wrapper in the vapi to call size as well). Perhaps a property instead of a method, for consistency with string.data?

In Socket, you could deal with a errno return code with a static method instead of a constructor.

Perhaps POLL* should be in a namespace? You could even put the PollItem struct and poll function in there

Perhaps device should be in the Device enum?
Comment 2 Lewis Gunsch 2011-08-26 20:03:40 UTC
I am having some troubles with the Msg struct and copying. Looks like I may be blocked by https://bugzilla.gnome.org/show_bug.cgi?id=645852. Socket.send owns the message, and then makes a copy before the method call to zmq_send. Vala puts the copy parameters in the wrong order (ZMQ has their copy method paramters reversed from normal), and also copies without initializing the temporary variable first. If a temporary Msg variable is used in the copy, it must be initialized first; otherwise, a segmentation fault is produced.
Comment 3 Lewis Gunsch 2011-09-07 16:02:28 UTC
Created attachment 195900 [details] [review]
ZeroMQ bindings patch
Comment 4 Lewis Gunsch 2011-09-07 16:06:14 UTC
Comment on attachment 195900 [details] [review]
ZeroMQ bindings patch

This new patch should address the issues noted.

However, there is still problem with Vala not initializing the temporary variables it creates before use.
Comment 5 Luca Bruno 2011-09-07 16:33:22 UTC
(In reply to comment #4)
> However, there is still problem with Vala not initializing the temporary
> variables it creates before use.

Can you please be more specific?
Comment 6 Lewis Gunsch 2011-09-07 17:29:29 UTC
In Socket.send the Msg is owned, so Vala makes a copy of the message before the method call. If I set the Msg struct copy_function="zmq_msg_copy" it will use the copy function backwards (src, dst) instead of (dst, src), and also does not initialize the copy before use with zmq_msg_init() (this will cause a seg fault).

If I disable it with has_copy_function = false, it will create one called "zmq_msg_copy" which conflicts with ZMQ's version. If I set copy_function = "", it will compile, but it will still use a temporary zmq_msg_t variable that is not initialized. Currently, its set to copy_function="".

You can see this with the hwserver and hwclient examples: 

https://github.com/lgunsch/zmq-vala/blob/master/examples/hwserver.vala
https://github.com/lgunsch/zmq-vala/blob/master/examples/hwclient.vala
Comment 7 Luca Bruno 2011-09-07 17:36:15 UTC
It probably makes sense to turn Msg into a compact class then. At all, I wouldn't mind implicitly copying a message, rather explicitly doing it with .copy() as it might be an heavy operation.
Comment 8 Evan Nemerson 2011-09-16 06:57:38 UTC
Have you considered binding czmq (http://czmq.zeromq.org/manual:czmq) instead of libzmq? It seems like it would be a bit more friendly towards Vala...
Comment 9 Lewis Gunsch 2011-09-19 16:22:15 UTC
Created attachment 196961 [details] [review]
Add ZeroMQ Bindings.

CZMQ does look quite a bit more friendly towards Vala. It adds quite a bit more functionality as well. I will create bindings for it as well.

Also, since I changed the send msg from owned, to ref, all my issues have disappeared and ZMQ works as expected now. I also have a good set of examples of use.
Comment 10 Evan Nemerson 2014-06-12 21:48:21 UTC
Added to vala-extra-vapis


commit b4b13bfff9b7ab069313ae344eab3a7cc2376641
Author: Lewis Gunsch <lewis@gunsch.ca>
Date:   Thu Jun 12 14:46:31 2014 -0700

    Add libzmq bindings.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=655282