Class: Fiddle::Pinned
- Inherits:
-
Object
- Object
- Fiddle::Pinned
- Defined in:
- lib/fiddle/ffi_backend.rb,
ext/fiddle/pinned.c
Instance Method Summary collapse
-
#clear ⇒ Object
Clear the reference to the object this is pinning.
-
#cleared? ⇒ Boolean
Returns true if the reference has been cleared, otherwise returns false.
-
#Fiddle::Pinned.new(object) ⇒ Object
constructor
Create a new pinned object reference.
-
#ref ⇒ Object
Return the object that this pinned instance references.
Constructor Details
#Fiddle::Pinned.new(object) ⇒ Object
Create a new pinned object reference. The Fiddle::Pinned instance will prevent the GC from moving object
.
52 53 54 |
# File 'ext/fiddle/pinned.c', line 52 def initialize(object) @object = object end |
Instance Method Details
#clear ⇒ Object
Clear the reference to the object this is pinning.
83 84 85 |
# File 'ext/fiddle/pinned.c', line 83 def clear @object = nil end |
#cleared? ⇒ Boolean
Returns true if the reference has been cleared, otherwise returns false.
97 98 99 |
# File 'ext/fiddle/pinned.c', line 97 def cleared? @object.nil? end |
#ref ⇒ Object
Return the object that this pinned instance references.
66 67 68 69 70 71 |
# File 'ext/fiddle/pinned.c', line 66 def ref if @object.nil? raise ClearedReferenceError, "`ref` called on a cleared object" end @object end |