class Concurrent::Transaction

def write(tvar, value)

def write(tvar, value)
  # Have we already written to this TVar?
  unless @write_log.has_key? tvar
    # Try to lock the TVar
    unless tvar.unsafe_lock.try_lock
      # Someone else is writing to this TVar - abort
      Concurrent::abort_transaction
    end
    # If we previously wrote to it, check the version hasn't changed
    @read_log.each do |log_entry|
      if log_entry.tvar == tvar and tvar.unsafe_version > log_entry.version
        Concurrent::abort_transaction
      end
    end
  end
  # Record the value written
  @write_log[tvar] = value
end