Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Execute Array#each blocks in parallel using JDK7's concurrency with JRuby
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.rvmrc
.travis.yml
.watchr
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
forkit.gemspec

README.md

Overview

Forkit is an extremely simple gem to make leveraging multiple cores on long-running array iterations easy. It encapsulates Java's ForkJoinPool and RecursiveAction behind a simple #each call on a Ruby array. The number of cores that will be used is based on the value returned by Runtime.availableProcessors().

For more information on the Java API, see:

Requirements

  • JRuby 1.6.5 +
  • JDK 7 +

Environment

  • JRUBY_OPTS="--1.9 --server -Xinvokedynamic.constants=true"
  • RUBYOPT="rubygems"

Installation

In your Gemfile:

gem "forkit"

In your application:

require "forkit"

Usage

# Execute the block for each element in the array, using multiple cores
# if available.
array.forked.each do |object|
  object.some_expensive_action
end

# Execute the block for each element in the array, but for any size under
# 100000 objects execute synchronously.
array.forked(100000).each do |object|
  object.some_expensive_action
end

Running Specs

rake
Something went wrong with that request. Please try again.