class Fiddle::Pinned

Public Class Methods

Source
# File ext/fiddle/lib/fiddle/jruby.rb, line 530
def initialize(object)
  @object = object
end
Source
static VALUE
initialize(VALUE self, VALUE ref)
{
    struct pinned_data *data;
    TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
    RB_OBJ_WRITE(self, &data->ptr, ref);
    return self;
}

Create a new pinned object reference. The Fiddle::Pinned instance will prevent the GC from moving object.

Public Instance Methods

Source
# File ext/fiddle/lib/fiddle/jruby.rb, line 541
def clear
  @object = nil
end

Clear the reference to the object this is pinning.

Source
# File ext/fiddle/lib/fiddle/jruby.rb, line 545
def cleared?
  @object.nil?
end

Returns true if the reference has been cleared, otherwise returns false.

Source
# File ext/fiddle/lib/fiddle/jruby.rb, line 534
def ref
  if @object.nil?
    raise ClearedReferenceError, "`ref` called on a cleared object"
  end
  @object
end

Return the object that this pinned instance references.