Permalink
Browse files

Make get_and_set atomic in the same way JDK does.

  • Loading branch information...
1 parent 6c6f00e commit d8fe1a0a0def69475bac799d1616339b01d03630 @headius headius committed Nov 30, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 kernel/bootstrap/atomic.rb
@@ -15,9 +15,10 @@ def compare_and_set(old, new)
end
def get_and_set(new)
- val = @value
- @value = new
- val
+ while true
+ val = get
+ return val if compare_and_set(val, new)
+ end
end
end
end

0 comments on commit d8fe1a0

Please sign in to comment.