Sha256: 45292403454297eb324cae590e29c23fd9a8be80467ea4a6330b2571d74a5a74

Contents?: true

Size: 1.81 KB

Versions: 103

Compression:

Stored size: 1.81 KB

Contents

require 'concurrent/synchronization/abstract_lockable_object'

module Concurrent
  module Synchronization

    # @!visibility private
    # @!macro internal_implementation_note
    module ConditionSignalling
      protected

      def ns_signal
        @__Condition__.signal
        self
      end

      def ns_broadcast
        @__Condition__.broadcast
        self
      end
    end


    # @!visibility private
    # @!macro internal_implementation_note
    class MutexLockableObject < AbstractLockableObject
      include ConditionSignalling

      safe_initialization!

      def initialize
        super()
        @__Lock__      = ::Mutex.new
        @__Condition__ = ::ConditionVariable.new
      end

      def initialize_copy(other)
        super
        @__Lock__      = ::Mutex.new
        @__Condition__ = ::ConditionVariable.new
      end

      protected

      def synchronize
        if @__Lock__.owned?
          yield
        else
          @__Lock__.synchronize { yield }
        end
      end

      def ns_wait(timeout = nil)
        @__Condition__.wait @__Lock__, timeout
        self
      end
    end

    # @!visibility private
    # @!macro internal_implementation_note
    class MonitorLockableObject < AbstractLockableObject
      include ConditionSignalling

      safe_initialization!

      def initialize
        super()
        @__Lock__      = ::Monitor.new
        @__Condition__ = @__Lock__.new_cond
      end

      def initialize_copy(other)
        super
        @__Lock__      = ::Monitor.new
        @__Condition__ = @__Lock__.new_cond
      end

      protected

      def synchronize # TODO may be a problem with lock.synchronize { lock.wait }
        @__Lock__.synchronize { yield }
      end

      def ns_wait(timeout = nil)
        @__Condition__.wait timeout
        self
      end
    end
  end
end

Version data entries

103 entries across 103 versions & 16 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
concurrent-ruby-1.3.4 lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
concurrent-ruby-1.3.3 lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
concurrent-ruby-1.3.2 lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.1/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
concurrent-ruby-1.3.1 lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
concurrent-ruby-1.3.1.pre lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
concurrent-ruby-1.2.3 lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb