Class: FFI::AutoPointer::Releaser Abstract
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/autopointer.rb
Overview
This class is abstract.
Base class for FFI::AutoPointer‘s releasers.
All subclasses of Releaser should define a #release(ptr) method.
A releaser is an object in charge of release an FFI::AutoPointer.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#autorelease ⇒ Object
Returns the value of attribute autorelease.
Instance Method Summary collapse
-
#call(*args) ⇒ Object
Release pointer if
autorelease
is set. -
#free ⇒ nil
Free pointer.
-
#initialize(ptr, proc) ⇒ nil
constructor
A new instance of Releaser.
Constructor Details
#initialize(ptr, proc) ⇒ nil
A new instance of Releaser.
130 131 132 133 134 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/autopointer.rb', line 130 def initialize(ptr, proc) @ptr = ptr @proc = proc @autorelease = true end |
Instance Attribute Details
#autorelease ⇒ Object
Returns the value of attribute autorelease.
124 125 126 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/autopointer.rb', line 124 def autorelease @autorelease end |
Instance Method Details
#call(*args) ⇒ Object
Release pointer if autorelease
is set.
149 150 151 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/autopointer.rb', line 149 def call(*args) release(@ptr) if @autorelease && @ptr end |
#free ⇒ nil
Free pointer.
138 139 140 141 142 143 144 145 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/autopointer.rb', line 138 def free if @ptr release(@ptr) @autorelease = false @ptr = nil @proc = nil end end |