It's an interesting use case. The simplest answer is to indeed pull off messages in user space and only process a message when the client queues appear empty.
It's a fairly common strategy in older pub-sub systems to drop oldest data or conflate data (so newer keys replace older ones) but it costs a lot in CPU and slows things down. If you want to make an experimental patch on ROUTER, go for it. Try to find a name that explains what you're really doing, which is to limit the incoming queue for each client to one request. (ZMQ_ROUTER_CONFLATE?) Also, if this can work on other socket types, it probably should. -Pieter On Fri, Jun 7, 2013 at 11:53 AM, Daniel Krikun <[email protected]> wrote: > Hi all, > > I have a setup, where a server does graphics rendering based on client > requests, that is, clients send geometric data (position, orientation, > etc.) and the server runs in cycles: process incoming messages and do > some rendering. > Occasionally, the clients might be faster and few messages get > themselves queued on the server queue. However, only the most recent > message is of interest as the server does not renders the objects as > they were a couple of cycles before. > > To solve the problem, I have extended the ZMQ_ROUTER socket (via > subclassing) so that it has a background thread that empties the > socket message queue and stores the last message. The message is > stored in a double-buffer (one for each client, this is why I need a > router socket type). Then, when the server calls recv() on my extended > socket, it gets one of the stored messages (if there are any). > > I ask myself whether some similar functionality should be put inside > zeromq (say, under ZMQ_FLAT_PULL socket type), left as is in a "user > space" or maybe I should use UDP instead? > > > Thank you, > > -- > Daniel Krikun > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
