-
Notifications
You must be signed in to change notification settings - Fork 420
[Improvement] - Initial implementation of Concurrent::AtomicBoolean in pure Java #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f547d76
to
4523c40
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should return result of compareAndSet
rather than always nil
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some rules around it. I got some falling specs so now I'm fixing them. Thanks for pointing it out.
fd794d9
to
39ca9db
Compare
1 similar comment
[Improvement] - Initial implementation of Concurrent::AtomicBoolean in pure Java
@lucasallan Did you have an opportunity to run performance tests to verify that this approach is faster? |
@jdantonio yes, I did and looks good (similar to the results we got on |
But as you can see in this preview: Java Version
JRuby Version
Ruby code: require 'concurrent'
require 'benchmark'
NUM = 50_000_000
if defined? JRUBY_VERSION
puts "~~~ JRuby version: #{JRUBY_VERSION}"
Benchmark.bm do |stats|
e = Concurrent::AtomicFixnum.new()
puts "Benchmarking Concurrent::AtomicFixnum#up..."
stats.report do
NUM.times { e.up }
end
puts "Benchmarking Concurrent::AtomicFixnum#down..."
stats.report do
NUM.times { e.down }
end
puts "Benchmarking Concurrent::AtomicFixnum#value..."
stats.report do
NUM.times { e.value }
end
end
end |
Awesome! Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could also be getRuntime().newBoolean(atomicBoolean.compareAndSet(false, true))
.
@jdantonio @pitr-ch Could you guys review this pull request?