Sha256: bd7d0b4db6aaaf1dce3e1297b4e49be808da0b233801fc5afb6e4d05733fca54

Contents?: true

Size: 835 Bytes

Versions: 6

Compression:

Stored size: 835 Bytes

Contents

module Concurrent
  module Synchronization

    # @!visibility private
    # @!macro internal_implementation_note
    class MriObject < AbstractObject

      def initialize
        # nothing to do
      end

      def full_memory_barrier
        # 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

      def self.attr_volatile(*names)
        names.each do |name|
          ivar = :"@volatile_#{name}"
          class_eval <<-RUBY, __FILE__, __LINE__ + 1
            def #{name}
          #{ivar}
            end

            def #{name}=(value)
              #{ivar} = value
            end
          RUBY
        end
        names.map { |n| [n, :"#{n}="] }.flatten
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
concurrent-ruby-1.0.0.pre4-java lib/concurrent/synchronization/mri_object.rb
concurrent-ruby-1.0.0.pre4 lib/concurrent/synchronization/mri_object.rb
concurrent-ruby-1.0.0.pre3-java lib/concurrent/synchronization/mri_object.rb
concurrent-ruby-1.0.0.pre3 lib/concurrent/synchronization/mri_object.rb
concurrent-ruby-1.0.0.pre2-java lib/concurrent/synchronization/mri_object.rb
concurrent-ruby-1.0.0.pre2 lib/concurrent/synchronization/mri_object.rb