return values from fork: fork_and_return
revert any side-effects like require or memory leaks and still get a result fork_and_return
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
revert any side-effects like require or memory leaks and still get a result fork_and_return
Comments
gem install fork
require ‘fork’ Fork.return { 1+1 } # => 2I think it doesn’t get any simpler than that :D
oh, also if you don’t need the result immediately, the fork gem allows you to do:
future = Fork.future { complex_calculation } # another complex calculation future.call # => result
Post a comment