class Concurrent::Synchronization::RbxLockableObject
@!visibility private @!macro internal_implementation_note
Public Class Methods
Source
# File lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb, line 9 def initialize(*defaults) super(*defaults) @__Waiters__ = [] @__owner__ = nil end
Calls superclass method
Concurrent::Synchronization::Object::new
Public Instance Methods
Source
# File lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb, line 15 def initialize_copy(other) super @__Waiters__ = [] @__owner__ = nil end
Calls superclass method
Protected Instance Methods
Source
# File lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb, line 65 def ns_broadcast @__Waiters__.shift << true until @__Waiters__.empty? self end
Source
# File lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb, line 60 def ns_signal @__Waiters__.shift << true unless @__Waiters__.empty? self end
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
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