class Concurrent::Synchronization::RbxLockableObject
@!visibility private @!macro internal_implementation_note
Public Class Methods
new(*defaults)
click to toggle source
Calls superclass method
Concurrent::Synchronization::Object.new
# File lib/concurrent/synchronization/rbx_lockable_object.rb, line 9 def initialize(*defaults) super(*defaults) @__Waiters__ = [] @__owner__ = nil end
Protected Instance Methods
ns_broadcast()
click to toggle source
# File lib/concurrent/synchronization/rbx_lockable_object.rb, line 59 def ns_broadcast @__Waiters__.shift << true until @__Waiters__.empty? self end
ns_signal()
click to toggle source
# File lib/concurrent/synchronization/rbx_lockable_object.rb, line 54 def ns_signal @__Waiters__.shift << true unless @__Waiters__.empty? self end
ns_wait(timeout = nil)
click to toggle source
# File lib/concurrent/synchronization/rbx_lockable_object.rb, line 34 def ns_wait(timeout = nil) wchan = Rubinius::Channel.new begin @__Waiters__.push wchan Rubinius.unlock(self) signaled = wchan.receive_timeout timeout ensure Rubinius.lock(self) if !signaled && !@__Waiters__.delete(wchan) # we timed out, but got signaled afterwards, # so pass that signal on to the next waiter @__Waiters__.shift << true unless @__Waiters__.empty? end end self end
synchronize() { || ... }
click to toggle source
# File lib/concurrent/synchronization/rbx_lockable_object.rb, line 17 def synchronize(&block) if @__owner__ == Thread.current yield else result = nil Rubinius.synchronize(self) do begin @__owner__ = Thread.current result = yield ensure @__owner__ = nil end end result end end