我想我对赛璐珞池的理解有点被打破了。我将尝试在下面解释,但在此之前快速说明。
注意:我们的系统是针对fast client
通过 ZeroMQ 传递的消息运行的。
使用以下香草赛璐珞应用程序
class VanillaClient include Celluloid::ZMQ def read loop { async.evaluate_response(socket.read_multipart) end def evaluate_response(data) ## the reason for using defer can be found over here. Celluloid.defer do ExternalService.execute(data) end end end
我们的系统在一段时间后导致失败,原因 'Can't spawn more thread'
(或类似的东西)
所以我们打算使用赛璐珞池(避免上述问题),这样我们就可以限制产生的线程数
我对赛璐珞池的理解是赛璐珞池为你维护了一个演员池,这样你就可以并行分配你的任务。
因此,我决定对其进行测试,但根据我的测试用例,它似乎是串行的(即事情永远不会分发或并行发生。)
复制此示例。
## Send message `1` to the the_client.rb
## Send message `2` to the the_client.rb
## take message from sender-1 and sender-2 and return it back to receiver.rb
## heads on, the `sleep` is introduced to test/replicate the IO block that happens in the actual code.
## print the message obtained from the_client.rb
如果,sender-2.rb
在sender-1.rb
使用由20
_ _the_client.rb
sender-1.rb
它在 ruby-2.2.2 和 jRuby-9.0.5.0 下的行为相同。池以这种方式行事的可能原因是什么?