I'm not sure how Cinder works internally but I guess it is similar to OpenFrameworks. It then probably will be typical 'game loop' based. So running anything blocking kills the framerate. You can do a poll with 0 timeout but better would be to replace the sleeping of the loop with polling. Again I don't know how it's done in Cinder but I guess you'd need to write a custom apploop instance.
I'm actually curious how this could be done most efficient. I've done something similar in a experimental framework in Python: https://github.com/sphaero/sphof/blob/master/sphof/actors.py#L203 Rg, Arnaud On 2015-11-13 21:36, Doron Somech wrote: > Why not adding exactly this to the cookbook together with the > problem? > > On Nov 13, 2015 21:11, "Sridhar Anandakrishnan" <sx...@psu.edu [13]> > wrote: > >> here is a stub: >> >> zmq_pollitem_t items[] = { >> { mtySock, 0, ZMQ_POLLIN, 0 >> }, // moriarty (req/rep socket) >> { pktSUB, 0, ZMQ_POLLIN, 0 >> }, // raw packets (sub socket) >> { zyreStatusSock, 0, ZMQ_POLLIN, 0 }, // >> zyre status (sub socket) >> { NULL, inotifyFD, ZMQ_POLLIN, 0 } >> // inotify (unix file desc) >> }; >> >> int npoll = sizeof(items) / sizeof(items[0]); >> int timeout = 1000; >> >> while(!zctx_interrupted) { >> >> ret = zmq_poll (items, npoll, timeout); >> if (ret == 0) { >> // timeout >> } >> if (ret < 0) { >> if(zctx_interrupted) >> syslog(LOG_INFO, "zmq_poll received >> interrupt - exiting."); >> break; >> } >> >> if (items[0].revents == ZMQ_POLLIN) { >> // handle REQ-REP >> } >> if (items[1].revents == ZMQ_POLLIN) { // handle pkts >> // get a packet >> } >> >> and so on.. >> >> Sridhar >> >> > On Nov 13, 2015, at 2:02 PM, Bruce Lane <brucelan...@gmail.com >> [1]> wrote: >> > >> > thank you Pieter, could you point me to the right sample for >> polling? >> > >> > On 13 November 2015 at 16:58, Pieter Hintjens <p...@imatix.com [2]> >> wrote: >> > You should poll the socket and only receive when there is input. >> > >> > On Fri, Nov 13, 2015 at 2:06 PM, Bruce Lane >> <brucelan...@gmail.com [3]> wrote: >> > > hi, >> > > Im building this block >> https://github.com/brucelane/Cinder-ZeroMQ [4] for the >> > > Cinder C++ framework. >> > > >> > > what is the way to use a zeroMQ responder without the execution >> paused at >> > > zmq_recv (responder, buffer, 10, 0)? >> > > Shall I use a separate thread or there is another way, like >> something else >> > > than a responder? >> > > >> > > Bruce _______________________________________________ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev