Forkjoin gem

I finally got around to releasing a JRuby ext that wraps the fork/join
framework from Java 7. As a bonus, I used the externally available
jsr166y version, so it works on Java 5 and 6 too.

gem install forkjoin

forkjoin for JRuby

This is a small extension that wraps the JSR166y “Fork/Join”
framework in an efficient way for JRuby.


require 'forkjoin'

pool =


# Add a job (a proc) to the pool for each line
map_futures = pool.invoke_all({|line| ->{{|word| [word,1]}}}

# Get aggregate results
counts ={}) {|map, value|
  value.each {|k,v| (map[k] ||= []) << v}


# Add a job to the pool for each count in the map
reduced_futures = pool.invoke_all({|k, vs| ->{[k, vs.size]}}

# Print out results (or you could "reduce" some other way){|value|
  puts "%s %d\n" % value
  • Charlie

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs