Shared Variable Among Ruby Processes

后端 未结 4 664
臣服心动
臣服心动 2021-02-01 09:28

I have a Ruby program that loads up two very large yaml files, so I can get some speed-up by taking advantage of the multiple cores by forking off some processes. I\'ve tried lo

4条回答
  •  时光取名叫无心
    2021-02-01 09:35

    You probably want to use a thread instead of a fork if you want to share data.

    http://ruby-doc.org/docs/ProgrammingRuby/html/tut_threads.html

    Oh, and if you really want to take advantage of threads you'll want to use JRuby. In [c]Ruby 1.9 you may alway want to take a look at fibers. I haven't looked at them though, I don't know if it is a solution for you.

提交回复
热议问题