-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for function callbacks to REQ/REP and PUB/SUB sockets #25
Comments
In the discussion thread I asked for use case. Haven't got any answer though. In any case, 0MQ cannot provide callbacks because it has no spare thread to call the callback function from. |
I'm going to add this as some syntactic sugar in a new ruby library I am starting up soon. Briefly, here is my use case. Allow for the creation of multiple reactors (one per thread and context). All send/recv operations are async but are implemented inside of coroutines/fibers/cooperative threads so that they "block." Incoming messages will awaken the coroutine and resume processing. This allows for writing code in a synchronous style while getting asynchronous performance out of the library. If this doesn't sound interesting, feel free to close this ticket. I'll send you a pointer to my library as I make progress. |
Yes. It's definitely intereseting, but it should be done outside of core 0MQ library (exactly as you are up to). There are several reasons for that. One of them is that it would require 0MQ to manage a pool of "callback threads". Another is that well-behaved hardcore C library is expected to keep the user in the control rather than controlling the user. Yet another is that callbacks are inherently complex to expose via different languege APIs (bindings). One more: 0MQ's long-term goal is to intergrate messaging with POSIX socket API which has no callbacks. |
Merged fix for zeromq#1382
issue zeromq#25 try to guess wifi nic
Per a discussion in the comments here: http://www.zeromq.org/blog:multithreaded-server
Expand the 0mq socket api to allow for attaching callbacks to REQ sockets on send. The callback should be invoked when its matching response arrives.
Similarly, allow for attaching callbacks to SUB sockets. All incoming messages should be passed to the callback for processing.
While these features can currently be built on top of the existing api via zmq_poll, it would be cleaner to have it available as part of the supported api.
The text was updated successfully, but these errors were encountered: