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