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-ruby/concurrent/synchronization/rbx_lockable_object.rb, line 9 def initialize(*defaults) super(*defaults) @__Waiters__ = [] @__owner__ = nil end
Public Instance Methods
initialize_copy(other)
click to toggle source
Calls superclass method
# File lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb, line 15 def initialize_copy(other) super @__Waiters__ = [] @__owner__ = nil end
Protected Instance Methods
ns_broadcast()
click to toggle source
# File lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb, line 65 def ns_broadcast @__Waiters__.shift << true until @__Waiters__.empty? self end
ns_signal()
click to toggle source
# File lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb, line 60 def ns_signal @__Waiters__.shift << true unless @__Waiters__.empty? self end
ns_wait(timeout = nil)
click to toggle source
# File lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb, line 40 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-ruby/concurrent/synchronization/rbx_lockable_object.rb, line 23 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