class Concurrent::TVar

{include:file:docs-source/tvar.md}
@!macro thread_safe_variable_comparison
is used as part of a transaction - see ‘Concurrent::atomically`.
A `TVar` is a transactional variable - a single-element container that

def initialize(value)

Create a new `TVar` with an initial value.
def initialize(value)
  @value = value
  @lock = Mutex.new
end

def unsafe_lock # :nodoc:

:nodoc:
@!visibility private
def unsafe_lock # :nodoc:
  @lock
end

def unsafe_value # :nodoc:

:nodoc:
@!visibility private
def unsafe_value # :nodoc:
  @value
end

def unsafe_value=(value) # :nodoc:

:nodoc:
@!visibility private
def unsafe_value=(value) # :nodoc:
  @value = value
end

def value

Get the value of a `TVar`.
def value
  Concurrent::atomically do
    Transaction::current.read(self)
  end
end

def value=(value)

Set the value of a `TVar`.
def value=(value)
  Concurrent::atomically do
    Transaction::current.write(self, value)
  end
end