Sha256: 2c6bade9a2358a7d81fb441e9be94e50b0d1a764847bee05c942ddc795046550

Contents?: true

Size: 1.44 KB

Versions: 180

Compression:

Stored size: 1.44 KB

Contents

module Concurrent
  module Synchronization

    # @!visibility private
    # @!macro internal_implementation_note
    class RbxLockableObject < AbstractLockableObject
      safe_initialization!

      def initialize(*defaults)
        super(*defaults)
        @__Waiters__ = []
        @__owner__   = nil
      end

      protected

      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

      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

      def ns_signal
        @__Waiters__.shift << true unless @__Waiters__.empty?
        self
      end

      def ns_broadcast
        @__Waiters__.shift << true until @__Waiters__.empty?
        self
      end
    end
  end
end

Version data entries

180 entries across 159 versions & 37 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.4/lib/concurrent/synchronization/rbx_lockable_object.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.3/lib/concurrent/synchronization/rbx_lockable_object.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
spiral_form-0.1.1 vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
spiral_form-0.1.0 vendor/bundle/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb