# class Fiddle::Pinned

### Public Class Methods

new (object)
Source

    # File ext/fiddle/lib/fiddle/ffi_backend.rb, line 557
    def initialize(object)
      @object = object
    end

Fiddle::Pinned.new(object) → pinned_object
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

clear ()
Source

    # File ext/fiddle/lib/fiddle/ffi_backend.rb, line 568
    def clear
      @object = nil
    end

Clear the reference to the object this is pinning.

cleared? ()
Source

    # File ext/fiddle/lib/fiddle/ffi_backend.rb, line 572
    def cleared?
      @object.nil?
    end

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

ref ()
Source

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

Return the object that this pinned instance references.