class Concurrent::MutexAtomicBoolean

@!macro internal_implementation_note
@!visibility private
@!macro atomic_boolean

def false?

@!macro atomic_boolean_method_false_question
def false?
  synchronize { !@value }
end

def initialize(initial = false)

@!macro atomic_boolean_method_initialize
def initialize(initial = false)
  super()
  @Lock = ::Mutex.new
  @value = !!initial
end

def make_false

@!macro atomic_boolean_method_make_false
def make_false
  synchronize { ns_make_value(false) }
end

def make_true

@!macro atomic_boolean_method_make_true
def make_true
  synchronize { ns_make_value(true) }
end

def ns_make_value(value)

@!visibility private
def ns_make_value(value)
  old = @value
  @value = value
  old != @value
end

def synchronize

@!visibility private
def synchronize
  if @Lock.owned?
    yield
  else
    @Lock.synchronize { yield }
  end
end

def true?

@!macro atomic_boolean_method_true_question
def true?
  synchronize { @value }
end

def value

@!macro atomic_boolean_method_value_get
def value
  synchronize { @value }
end

def value=(value)

@!macro atomic_boolean_method_value_set
def value=(value)
  synchronize { @value = !!value }
end