From my experience forking/process pooling is much more effective than thereadpooling in Ruby (assuming you do not need much in terms of thread communication). Some time ago I created a gem called process_pool, which is a very basic process pool with a file based job queue (you can check it out here: http://github.com/psyho/process_pool).
It's basically a port of the java.util.concurrent abstractions (including threadpools) to ruby -- except if you install it under Jruby, it'll use the java.util.concurrent stuff. So you can write code that'll work and do the same thing semantically (not neccesarily the same performance) under any ruby platform.
It also offers Futures, a higher level abstraction which may be more convenient to use than thread pools.
发布评论
评论(2)
根据我的经验,分叉/进程池比 Ruby 中的读取池更有效(假设您在线程通信方面不需要太多)。前段时间我创建了一个名为 process_pool 的 gem,它是一个非常基本的进程池,带有基于文件的作业队列(您可以在这里查看:http://github.com/psyho/process_pool)。
From my experience forking/process pooling is much more effective than thereadpooling in Ruby (assuming you do not need much in terms of thread communication). Some time ago I created a gem called process_pool, which is a very basic process pool with a file based job queue (you can check it out here: http://github.com/psyho/process_pool).
我会尝试 https://github.com/ruby-concurrency/concurrent-ruby/ .
它基本上是 java.util.concurrent 抽象(包括线程池)到 ruby 的端口——除非您将其安装在 Jruby 下,否则它将使用 java.util.concurrent 的东西。因此,您可以编写在任何 ruby 平台下都能工作并在语义上执行相同操作(不一定具有相同性能)的代码。
它还提供了 Futures,这是一种比线程池更方便使用的更高级别的抽象。
I would try https://github.com/ruby-concurrency/concurrent-ruby/ .
It's basically a port of the java.util.concurrent abstractions (including threadpools) to ruby -- except if you install it under Jruby, it'll use the java.util.concurrent stuff. So you can write code that'll work and do the same thing semantically (not neccesarily the same performance) under any ruby platform.
It also offers Futures, a higher level abstraction which may be more convenient to use than thread pools.