Running code asynchronously inside pollers

。_饼干妹妹 提交于 2019-12-05 20:32:07
digitalextremist

The question was 100% changed, so my previous answer does not help. Now, the issues are...

ZMQ::Poller is not part of Celluloid::ZMQ

You are directly using the ffi-rzmq bindings, and not using the Celluloid::ZMQ wrapping, which provides evented & threaded handling of the socket(s).

It would be best to make multiple actors -- one per socket -- or to just use Celluloid::ZMQ directly in one actor, rather than undermining it.

Your actor never gets time to work with the response

This part makes it a duplicate of:

The best answer is to use after or every and not loop ... which is dominating your actor.

You need to either:

  • Move evaluate_response to another actor.
  • Move each socket to their own actor.

This code needs to be broken up into several actors to work properly, with a main sleep at the end of the program. But before all that, try using after or every instead of loop.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!