Skip to content

Commit

Permalink
Merge pull request #23 from sferik/travis-ci
Browse files Browse the repository at this point in the history
Add Travis CI
  • Loading branch information
headius committed Oct 1, 2013
2 parents 400cd3c + b81bb5c commit 6d94ac4
Show file tree
Hide file tree
Showing 31 changed files with 53 additions and 38 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bundler_args: --without development
language: ruby
rvm:
- jruby-18mode
- jruby-19mode
- rbx-18mode
- rbx-19mode
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Threadsafe

[![Build Status](https://travis-ci.org/headius/thread_safe.png)](https://travis-ci.org/headius/thread_safe)

A collection of thread-safe versions of common core Ruby classes.

## Installation
Expand Down Expand Up @@ -28,7 +30,10 @@ sh = ThreadSafe::Hash.new # supports standard Hash.new forms
## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
2. Clone it (`git clone git@github.com:you/thread_safe.git`)
3. Create your feature branch (`git checkout -b my-new-feature`)
4. Build the jar (`rake jar`) NOTE: Requires JRuby
5. Install dependencies (`bundle install`)
6. Commit your changes (`git commit -am 'Added some feature'`)
7. Push to the branch (`git push origin my-new-feature`)
8. Create new Pull Request
6 changes: 2 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rake/testtask'
require "rake/testtask"

task :default => :test

if defined?(JRUBY_VERSION)
require 'ant'
require "ant"

directory "pkg/classes"

Expand Down Expand Up @@ -37,5 +37,3 @@ Rake::TestTask.new :test => :package do |t|
t.libs << "lib"
t.test_files = FileList["test/**/*.rb"]
end


2 changes: 1 addition & 1 deletion examples/bench_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
results.report('Cache#each_pair') do
(TESTS / ENTRIES).times { cache.each_pair {|k,v| v} }
end
end
end
4 changes: 2 additions & 2 deletions ext/org/jruby/ext/thread_safe/JRubyCacheBackendLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* Native Java implementation to avoid the JI overhead.
*
*
* @author thedarkone
*/
public class JRubyCacheBackendLibrary implements Library {
Expand All @@ -26,7 +26,7 @@ public void load(Ruby runtime, boolean wrap) throws IOException {
jrubyRefClass.setAllocator(BACKEND_ALLOCATOR);
jrubyRefClass.defineAnnotatedMethods(JRubyCacheBackend.class);
}

private static final ObjectAllocator BACKEND_ALLOCATOR = new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
return new JRubyCacheBackend(runtime, klazz);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3839,4 +3839,4 @@ public sun.misc.Unsafe run() throws Exception {
}
}
}
}
}
2 changes: 1 addition & 1 deletion ext/org/jruby/ext/thread_safe/jsr166e/LongAdder.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@ private void readObject(ObjectInputStream s)
base = s.readLong();
}

}
}
2 changes: 1 addition & 1 deletion ext/org/jruby/ext/thread_safe/jsr166e/Striped64.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,4 @@ public sun.misc.Unsafe run() throws Exception {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,4 @@ public double nextDouble(double least, double bound) {
}

private static final long serialVersionUID = -5851777807851030925L;
}
}
4 changes: 2 additions & 2 deletions ext/thread_safe/JrubyCacheBackendService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package thread_safe;

import java.io.IOException;

import org.jruby.Ruby;
import org.jruby.ext.thread_safe.JRubyCacheBackendLibrary;
import org.jruby.runtime.load.BasicLibraryService;
Expand All @@ -12,4 +12,4 @@ public boolean basicLoad(final Ruby runtime) throws IOException {
new JRubyCacheBackendLibrary().load(runtime, false);
return true;
}
}
}
2 changes: 1 addition & 1 deletion lib/thread_safe/atomic_reference_cache_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -919,4 +919,4 @@ def decrement_size(by = 1)
@counter.add(-by)
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ def validate_options_hash!(options)
end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/thread_safe/mri_cache_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class MriCacheBackend < NonConcurrentCacheBackend
#
# The previous implementation used `Thread.critical` on 1.8 MRI to implement the 4 composed atomic operations (`put_if_absent`, `replace_pair`,
# `replace_if_exists`, `delete_pair`) this however doesn't work for `compute_if_absent` because on 1.8 the Mutex class is itself implemented
# via `Thread.critical` and a call to `Mutex#lock` does not restore the previous `Thread.critical` value (thus any synchronisation clears the
# via `Thread.critical` and a call to `Mutex#lock` does not restore the previous `Thread.critical` value (thus any synchronisation clears the
# `Thread.critical` flag and we loose control). This poses a problem as the provided block might use synchronisation on its own.
#
# NOTE: a neat idea of writing a c-ext to manually perform atomic put_if_absent, while relying on Ruby not releasing a GVL while calling
Expand Down Expand Up @@ -59,4 +59,4 @@ def clear
WRITE_LOCK.synchronize { super }
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/non_concurrent_cache_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ def store_computed_value(key, new_value)
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/synchronized_cache_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ def dupped_backend
synchronize { super }
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/synchronized_delegator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(*)
super
@mutex = Mutex.new
end

def method_missing(m, *args, &block)
begin
mutex = @mutex
Expand Down
2 changes: 1 addition & 1 deletion lib/thread_safe/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ module Util
autoload :VolatileTuple, 'thread_safe/util/volatile_tuple'
autoload :XorShiftRandom, 'thread_safe/util/xor_shift_random'
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/util/adder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ def reset
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/util/atomic_reference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ module Util
defined?(Atomic::InternalReference) ? Atomic::InternalReference : Atomic
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/util/cheap_lockable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ def cheap_broadcast
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/util/power_of_two_tuple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ def next_in_size_table
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/util/striped64.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,4 @@ def try_in_busy
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/util/volatile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ def compare_and_set_#{attr_name}(old_value, new_value)
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/util/volatile_tuple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def each
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thread_safe/util/xor_shift_random.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def xorshift(x)
end
end
end
end
end
2 changes: 1 addition & 1 deletion test/test_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def test_concurrency
end.map(&:join)
end
end
end
end
2 changes: 1 addition & 1 deletion test/test_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,4 @@ def assert_merge_pair(key, value, expected_old_value, expected_result)
end
assert_equal expected_result, result
end
end
end
2 changes: 1 addition & 1 deletion test/test_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def test_concurrency
end.map(&:join)
end
end
end
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ def self.HashCollisionKey(key)
HASH_COLLISION_CLASSES[rand(4)].new(key)
end
end
end
end
2 changes: 1 addition & 1 deletion test/test_synchronized_delegator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_synchronizes_access
Thread.pass until t2_continue
sync_ary << 2
end

Thread.pass until t2.status == 'sleep'
assert_equal 1, ary.size

Expand Down
1 change: 1 addition & 0 deletions thread_safe.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Gem::Specification.new do |gem|
gem.license = "Apache-2.0"

gem.add_dependency 'atomic'
gem.add_development_dependency 'rake'
end

0 comments on commit 6d94ac4

Please sign in to comment.