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
logstash-output-scalyr-0.1.5 vendor/bundle/jruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
logstash-output-scalyr-0.1.5 vendor/bundle/jruby/2.5.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
logstash-output-scalyr-0.1.4 vendor/bundle/jruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
logstash-output-scalyr-0.1.4 vendor/bundle/jruby/2.5.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
logstash-output-scalyr-0.1.3 vendor/bundle/jruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
logstash-output-scalyr-0.1.3 vendor/bundle/jruby/2.5.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.4/lib/concurrent/synchronization/rbx_lockable_object.rb
logstash-output-scalyr-0.1.2 vendor/bundle/jruby/2.5.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
logstash-output-scalyr-0.1.2 vendor/bundle/jruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
concurrent-ruby-1.1.6 lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
concurrent-ruby-1.1.6.pre1 lib/concurrent-ruby/concurrent/synchronization/rbx_lockable_object.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/synchronization/rbx_lockable_object.rb