Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions ext/com/concurrent_ruby/ext/JavaAtomicBooleanLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
public static class JavaAtomicBoolean extends RubyObject {

private AtomicBoolean atomicBoolean;
private ThreadContext context;

public JavaAtomicBoolean(Ruby runtime, RubyClass metaClass) {
super(runtime, metaClass);
Expand All @@ -42,14 +41,12 @@ public JavaAtomicBoolean(Ruby runtime, RubyClass metaClass) {
@JRubyMethod
public IRubyObject initialize(ThreadContext context, IRubyObject value) {
atomicBoolean = new AtomicBoolean(convertRubyBooleanToJavaBoolean(value));
this.context = context;
return context.nil;
}

@JRubyMethod
public IRubyObject initialize(ThreadContext context) {
atomicBoolean = new AtomicBoolean();
this.context = context;
return context.nil;
}

Expand All @@ -69,7 +66,7 @@ public IRubyObject isAtomicFalse() {
}

@JRubyMethod(name = "value=")
public IRubyObject setAtomic(IRubyObject newValue) {
public IRubyObject setAtomic(ThreadContext context, IRubyObject newValue) {
atomicBoolean.set(convertRubyBooleanToJavaBoolean(newValue));
return context.nil;
}
Expand Down
9 changes: 3 additions & 6 deletions ext/com/concurrent_ruby/ext/JavaAtomicFixnumLibrary.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.concurrent_ruby.ext;


import java.io.IOException;
import java.util.concurrent.atomic.AtomicLong;
import org.jruby.Ruby;
Expand All @@ -22,7 +23,6 @@ public void load(Ruby runtime, boolean wrap) throws IOException {
RubyClass atomicCls = concurrentMod.defineClassUnder("JavaAtomicFixnum", runtime.getObject(), JRUBYREFERENCE_ALLOCATOR);

atomicCls.defineAnnotatedMethods(JavaAtomicFixnum.class);

}

private static final ObjectAllocator JRUBYREFERENCE_ALLOCATOR = new ObjectAllocator() {
Expand All @@ -35,7 +35,6 @@ public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
public static class JavaAtomicFixnum extends RubyObject {

private AtomicLong atomicLong;
private ThreadContext context;

public JavaAtomicFixnum(Ruby runtime, RubyClass metaClass) {
super(runtime, metaClass);
Expand All @@ -44,14 +43,12 @@ public JavaAtomicFixnum(Ruby runtime, RubyClass metaClass) {
@JRubyMethod
public IRubyObject initialize(ThreadContext context) {
this.atomicLong = new AtomicLong(0);
this.context = context;
return context.nil;
}

@JRubyMethod
public IRubyObject initialize(ThreadContext context, IRubyObject value) {
this.atomicLong = new AtomicLong(rubyFixnumToLong(value));
this.context = context;
return context.nil;
}

Expand All @@ -61,7 +58,7 @@ public IRubyObject getValue() {
}

@JRubyMethod(name = "value=")
public IRubyObject setValue(IRubyObject newValue) {
public IRubyObject setValue(ThreadContext context, IRubyObject newValue) {
atomicLong.set(rubyFixnumToLong(newValue));
return context.nil;
}
Expand All @@ -77,7 +74,7 @@ public IRubyObject decrement() {
}

@JRubyMethod(name = "compare_and_set")
public IRubyObject compareAndSet(IRubyObject expect, IRubyObject update) {
public IRubyObject compareAndSet(ThreadContext context, IRubyObject expect, IRubyObject update) {
return RubyBoolean.newBoolean(getRuntime(), atomicLong.compareAndSet(rubyFixnumToLong(expect), rubyFixnumToLong(update)));
}

Expand Down