Sha256: 85ddaba87da5a5253d36a199d3347f40572f8081d76c483bf77e625756e47ab6

Contents?: true

Size: 948 Bytes

Versions: 13

Compression:

Stored size: 948 Bytes

Contents

# :stopdoc:
if ENV['NOKOGIRI_ID2REF'] || RUBY_PLATFORM !~ /java/
  Nokogiri::VERSION_INFO['refs'] = "id2ref"
else
  require 'weakling'
  Nokogiri::VERSION_INFO['refs'] = "weakling"
end

module Nokogiri
  class WeakBucket
    if Nokogiri::VERSION_INFO['refs'] == "weakling"
      @@bucket = Weakling::IdHash.new
      @@semaphore = Mutex.new

      def WeakBucket.get_object(cstruct)
        @@semaphore.synchronize do
          @@bucket[cstruct.ruby_node_pointer]
        end
      end

      def WeakBucket.set_object(cstruct, object)
        @@semaphore.synchronize do
          cstruct.ruby_node_pointer = @@bucket.add(object)
        end
      end

    else

      def WeakBucket.get_object(cstruct)
        ptr = cstruct.ruby_node_pointer
        ptr != 0 ? ObjectSpace._id2ref(ptr) : nil
      end

      def WeakBucket.set_object(cstruct, object)
        cstruct.ruby_node_pointer = object.object_id
      end
    end
  end
end
# :startdoc:

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
nokogiri-1.4.7-java lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.7-x86-mingw32 lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.7-x86-mswin32-60 lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.7 lib/nokogiri/ffi/weak_bucket.rb
search_biomodel-1.0.0 search_biomodel/ruby/1.8/gems/nokogiri-1.4.6/lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.6 lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.6-java lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.6-x86-mingw32 lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.6-x86-mswin32-60 lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.5-java lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.5 lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.5-x86-mswin32-60 lib/nokogiri/ffi/weak_bucket.rb
nokogiri-1.4.5-x86-mingw32 lib/nokogiri/ffi/weak_bucket.rb