module Concurrent::ThreadSafe::Util::CheapLockable

def cheap_broadcast

def cheap_broadcast
  JRuby.reference0(self).notify_all
end

def cheap_broadcast

Must only be called in +cheap_broadcast+'s block.
Wakes up all threads waiting for this object's +cheap_synchronize+ lock.
def cheap_broadcast
  if conditional_variable = @conditional_variable
    conditional_variable.broadcast
  end
end

def cheap_synchronize

def cheap_synchronize
  JRuby.reference0(self).synchronized { yield }
end

def cheap_synchronize

Non-reentrant Mutex#syncrhonize
def cheap_synchronize
  true until (my_mutex = mutex) || cas_mutex(nil, my_mutex = Mutex.new)
  my_mutex.synchronize { yield }
end

def cheap_wait

def cheap_wait
  JRuby.reference0(self).wait
end

def cheap_wait

Must only be called in +cheap_broadcast+'s block.
Releases this object's +cheap_synchronize+ lock and goes to sleep waiting for other threads to +cheap_broadcast+, reacquires the lock on wakeup.
def cheap_wait
  conditional_variable = @conditional_variable ||= ConditionVariable.new
  conditional_variable.wait(mutex)
end