Module: Inline::C::Pointer
- Defined in:
- lib/inline_acceleration.rb
Constant Summary collapse
- @@registered_pointers =
{}
Instance Attribute Summary collapse
-
#ruby_managed ⇒ Object
readonly
Returns the value of attribute ruby_managed.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #initialize(memory_address, ruby_managed = false) ⇒ Object
- #memory_address ⇒ Object
Instance Attribute Details
#ruby_managed ⇒ Object (readonly)
Returns the value of attribute ruby_managed.
434 435 436 |
# File 'lib/inline_acceleration.rb', line 434 def ruby_managed @ruby_managed end |
Instance Method Details
#==(other) ⇒ Object
456 457 458 |
# File 'lib/inline_acceleration.rb', line 456 def ==(other) (other.is_a? Pointer) && Inline::C.internal_c_functions_module.C_Pointer_equals(self.memory_address, other.memory_address) end |
#initialize(memory_address, ruby_managed = false) ⇒ Object
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/inline_acceleration.rb', line 436 def initialize(memory_address, ruby_managed=false) @memory_address = ValueSafe.new() @memory_address.value = memory_address @ruby_managed = ruby_managed if ruby_managed @@registered_pointers[self.object_id] = memory_address ObjectSpace.define_finalizer(self, lambda { |id| memory_address = @@registered_pointers.delete(id) if !@@registered_pointers.has_value?(memory_address) Inline::C.internal_c_functions_module.C_Pointer_free_memory(memory_address) end }) end end |
#memory_address ⇒ Object
452 453 454 |
# File 'lib/inline_acceleration.rb', line 452 def memory_address @memory_address.value end |