File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
lib/concurrent-ruby/concurrent Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -188,26 +188,29 @@ def read(tvar)
188
188
def write ( tvar , value )
189
189
# Have we already written to this TVar?
190
190
191
- unless @write_log . has_key? tvar
191
+ if @write_log . has_key? tvar
192
+ # Record the value written
193
+ @write_log [ tvar ] = value
194
+ else
192
195
# Try to lock the TVar
193
196
194
197
unless tvar . unsafe_lock . try_lock
195
198
# Someone else is writing to this TVar - abort
196
199
Concurrent ::abort_transaction
197
200
end
198
201
199
- # If we previously wrote to it, check the version hasn't changed
202
+ # Record the value written
203
+
204
+ @write_log [ tvar ] = value
205
+
206
+ # If we previously read from it, check the version hasn't changed
200
207
201
208
@read_log . each do |log_entry |
202
209
if log_entry . tvar == tvar and tvar . unsafe_version > log_entry . version
203
210
Concurrent ::abort_transaction
204
211
end
205
212
end
206
213
end
207
-
208
- # Record the value written
209
-
210
- @write_log [ tvar ] = value
211
214
end
212
215
213
216
def abort
You can’t perform that action at this time.
0 commit comments