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)
188188 def write ( tvar , value )
189189 # Have we already written to this TVar?
190190
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
192195 # Try to lock the TVar
193196
194197 unless tvar . unsafe_lock . try_lock
195198 # Someone else is writing to this TVar - abort
196199 Concurrent ::abort_transaction
197200 end
198201
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
200207
201208 @read_log . each do |log_entry |
202209 if log_entry . tvar == tvar and tvar . unsafe_version > log_entry . version
203210 Concurrent ::abort_transaction
204211 end
205212 end
206213 end
207-
208- # Record the value written
209-
210- @write_log [ tvar ] = value
211214 end
212215
213216 def abort
You can’t perform that action at this time.
0 commit comments