Sha256: a302b7f8a28fc4ff7c6b0af122a56e1e8b98f155dc102a3282e070730371369e

Contents?: true

Size: 940 Bytes

Versions: 23

Compression:

Stored size: 940 Bytes

Contents

module Concurrent
  module Synchronization

    # @!visibility private
    # @!macro internal_implementation_note
    class MutexObject < AbstractObject
      def initialize
        @__lock__      = ::Mutex.new
        @__condition__ = ::ConditionVariable.new
      end

      protected

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

      def ns_signal
        @__condition__.signal
        self
      end

      def ns_broadcast
        @__condition__.broadcast
        self
      end

      def ns_wait(timeout = nil)
        @__condition__.wait @__lock__, timeout
        self
      end

      def ensure_ivar_visibility!
        # relying on undocumented behavior of CRuby, GVL acquire has lock which ensures visibility of ivars
        # https://github.com/ruby/ruby/blob/ruby_2_2/thread_pthread.c#L204-L211
      end
    end
  end
end

Version data entries

23 entries across 21 versions & 5 rubygems

Version Path
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/concurrent-ruby-0.9.2-java/lib/concurrent/synchronization/mutex_object.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/concurrent-ruby-0.9.2-java/lib/concurrent/synchronization/mutex_object.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/concurrent-ruby-0.9.2-java/lib/concurrent/synchronization/mutex_object.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/concurrent-ruby-0.9.2-java/lib/concurrent/synchronization/mutex_object.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/concurrent-ruby-0.9.2-java/lib/concurrent/synchronization/mutex_object.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/concurrent-ruby-0.9.2-java/lib/concurrent/synchronization/mutex_object.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-codec-json-2.0.3/vendor/gems/concurrent-ruby-0.9.1-java/lib/concurrent/synchronization/mutex_object.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/concurrent-ruby-0.9.1-java/lib/concurrent/synchronization/mutex_object.rb
logstash-codec-json-2.0.3 vendor/gems/concurrent-ruby-0.9.1-java/lib/concurrent/synchronization/mutex_object.rb
concurrent-ruby-0.9.2-java lib/concurrent/synchronization/mutex_object.rb
concurrent-ruby-0.9.2 lib/concurrent/synchronization/mutex_object.rb
logstash-input-beats-0.9.2 vendor/jruby/1.9/gems/concurrent-ruby-0.9.1-java/lib/concurrent/synchronization/mutex_object.rb
logstash-input-beats-0.9.1 vendor/jruby/1.9/gems/concurrent-ruby-0.9.1-java/lib/concurrent/synchronization/mutex_object.rb
concurrent-ruby-1.0.0.pre1 lib/concurrent/synchronization/mutex_object.rb
concurrent-ruby-1.0.0.pre1-java lib/concurrent/synchronization/mutex_object.rb
concurrent-ruby-0.9.1 lib/concurrent/synchronization/mutex_object.rb
concurrent-ruby-0.9.1-java lib/concurrent/synchronization/mutex_object.rb
concurrent-ruby-0.9.0 lib/concurrent/synchronization/mutex_object.rb
concurrent-ruby-0.9.0-java lib/concurrent/synchronization/mutex_object.rb
concurrent-ruby-0.9.0.pre3-java lib/concurrent/synchronization/mutex_object.rb