Class: Babeltrace2::BTSharedObject

Inherits:
BTObject
  • Object
show all
Defined in:
lib/babeltrace2/types.rb

Defined Under Namespace

Classes: Releaser

Class Attribute Summary collapse

Attributes inherited from BTObject

#handle

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BTObject

#==, #to_ptr

Constructor Details

#initialize(handle, retain: false, auto_release: true) ⇒ BTSharedObject

Returns a new instance of BTSharedObject.



604
605
606
607
608
# File 'lib/babeltrace2/types.rb', line 604

def initialize(handle, retain: false, auto_release: true)
  super(handle)
  Babeltrace2.method(self.class.get_ref).call(handle) if retain
  ObjectSpace.define_finalizer(self, Releaser.new(handle, self.class.put_ref)) if auto_release
end

Class Attribute Details

.get_refObject (readonly)

Returns the value of attribute get_ref.



600
601
602
# File 'lib/babeltrace2/types.rb', line 600

def get_ref
  @get_ref
end

.put_refObject (readonly)

Returns the value of attribute put_ref.



601
602
603
# File 'lib/babeltrace2/types.rb', line 601

def put_ref
  @put_ref
end

Class Method Details

.inherited(child) ⇒ Object



595
596
597
598
# File 'lib/babeltrace2/types.rb', line 595

def self.inherited(child)
  child.instance_variable_set(:@get_ref, @get_ref)
  child.instance_variable_set(:@put_ref, @put_ref)
end