We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 13c6202 + c5073a0 commit 5a2235eCopy full SHA for 5a2235e
lib/concurrent/atom.rb
@@ -158,8 +158,8 @@ def swap(*args)
158
159
loop do
160
old_value = value
161
+ new_value = yield(old_value, *args)
162
begin
- new_value = yield(old_value, *args)
163
break old_value unless valid?(new_value)
164
break new_value if compare_and_set(old_value, new_value)
165
rescue
spec/concurrent/atom_spec.rb
@@ -151,6 +151,15 @@ module Concurrent
151
152
expect(counter.value).to be > 1
153
end
154
+
155
+ it 'reraises the exception from block' do
156
+ atom = Atom.new(0)
157
+ expect do
+ atom.swap do |value|
+ fail 'something went wrong'
+ end
+ end.to raise_error 'something went wrong'
context '#reset' do
0 commit comments