Skip to content
This repository

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

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 .watchr
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 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.