Permalink
Browse files

Prepare for 1.0.0 gem release.

  • Loading branch information...
headius committed Feb 17, 2012
1 parent 96ae7da commit 7739aacc7daa3da822767d9b4320dd1f674bbbb7
Showing with 65 additions and 10 deletions.
  1. +39 −0 README.md
  2. +4 −4 build.xml
  3. +17 −0 forkjoin.gemspec
  4. BIN javalib/jsr166y.jar
  5. +3 −4 lib/forkjoin.rb
  6. +2 −2 src/org/jruby/ext/ForkJoin.java
View
@@ -0,0 +1,39 @@
+forkjoin for JRuby
+==================
+
+This is a small extension that wraps the JSR166y "Fork/Join"
+framework in an efficient way for JRuby.
+
+Example
+-------
+
+```
+require 'forkjoin'
+
+pool = ForkJoin::Pool.new
+
+# FORK
+
+# Add a job (a proc) to the pool for each line
+map_futures = pool.invoke_all(
+ ARGF.each_line.map{|line| ->{line.split.map{|word| [word,1]}}}
+)
+
+# Get aggregate results
+counts = map_futures.map(&:get).inject({}) {|map, value|
+ value.each {|k,v| (map[k] ||= []) << v}
+ map
+}
+
+# JOIN
+
+# Add a job to the pool for each count in the map
+reduced_futures = pool.invoke_all(
+ counts.map{|k, vs| ->{[k, vs.size]}}
+)
+
+# Print out results (or you could "reduce" some other way)
+reduced_futures.map(&:get).each{|value|
+ puts "%s %d\n" % value
+}
+```
View
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="build" name="forkjoin.rb">
<property file="build.properties"/>
+ <property file="default.build.properties"/>
<property name="src.java" value="src"/>
<property name="target" value="target"/>
<property name="target.classes" value="${target}/classes"/>
<property name="jruby.jar" value="${jruby.home}/lib/jruby.jar"/>
- <property name="version.source" value="1.7"/>
- <property name="version.target" value="1.7"/>
<path id="build.classpath">
<pathelement location="${jruby.jar}"/>
+ <pathelement location="javalib/jsr166y.jar"/>
</path>
<target name="init">
@@ -22,14 +22,14 @@
</target>
<target depends="init" name="build" description="Compiles Java source files">
- <javac debug="true" includeAntRuntime="false" destdir="${target.classes}" source="${version.source}" target="${version.target}">
+ <javac debug="true" includeAntRuntime="false" destdir="${target.classes}" source="1.5" target="1.5">
<classpath refid="build.classpath"/>
<src path="${src.java}"/>
</javac>
</target>
<target depends="build" name="jar" description="Build a JAR file with the generated Java class files">
- <jar destfile="${target}/forkjoin.jar" basedir="${target.classes}">
+ <jar destfile="lib/forkjoin.jar" basedir="${target.classes}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
</manifest>
View
@@ -0,0 +1,17 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{forkjoin}
+ s.version = "1.0.0"
+ s.authors = ["Charles Oliver Nutter", "Nakamura Hiroshi"]
+ s.date = Time.now.strftime('%Y-%m-%d')
+ s.description = "A JRuby extension to efficiently wrap the JSR166 Fork/Join framework."
+ s.email = ["headius@headius.com", "nahi@ctor.org"]
+ s.files = Dir['lib/**/*'] + Dir['examples/**/*.rb'] + Dir['{README.md,forkjoin.gemspec}']
+ s.homepage = "http://github.com/headius/forkjoin.rb"
+ s.require_paths = ["lib"]
+ s.summary = "A JRuby wrapper around Fork/Join"
+ s.test_files = Dir["test/test*.rb"]
+ s.platform = "java"
+ s.add_dependency("jsr166y")
+end
View
Binary file not shown.
View
@@ -1,5 +1,4 @@
-# TODO: temporary definition
-
-require 'java'
-require File.expand_path('../target/forkjoin.jar', File.dirname(__FILE__))
+require 'jruby'
+require 'jsr166y.jar'
+require 'forkjoin.jar'
org.jruby.ext.ForkJoin.new.load(JRuby.runtime, false)
@@ -7,8 +7,8 @@
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.ForkJoinTask;
+import jsr166y.ForkJoinPool;
+import jsr166y.ForkJoinTask;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;

0 comments on commit 7739aac

Please sign in to comment.