I’m trying to consume a Java library in JRuby (Akka to be specific). It
requires that I do something like this:
https://gist.github.com/846707#file_atomic.java
new Atomic() {
public Void atomically() {
ref.set(refs.get() + 1);
return null;
}
}.execute();
I have tried implementing this in JRuby as follows:
https://gist.github.com/846707#file_jruby.rb
a = Class.new(Atomic) do
def init(ref)
@ref = ref
self
end
def atomically
ref.set(ref.get + 1)
end
end.new.init(refs).execute
But the JRuby example results in errors that suggest I am running
outside of a Transaction (i.e. I am not ACTUALLY executing my code in
the Atomic.atomically method.
Is that possible? Is there a better way to replicate the java code show
above?
Thanks!
-Joe