In Files

  • fiddle/closure.c

Parent

Fiddle::Pinned

Public Class Methods

Fiddle::Pinned.new(object) => pinned_object click to toggle source

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

 
               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;
}
            

Public Instance Methods

clear click to toggle source

Clear the reference to the object this is pinning.

 
               static VALUE
clear(VALUE self)
{
    struct pinned_data *data;
    TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
    data->ptr = 0;
    return self;
}
            
cleared? click to toggle source

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

 
               static VALUE
cleared_p(VALUE self)
{
    struct pinned_data *data;
    TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
    if (data->ptr) {
        return Qfalse;
    } else {
        return Qtrue;
    }
}
            
ref click to toggle source

Return the object that this pinned instance references.

 
               static VALUE
ref(VALUE self)
{
    struct pinned_data *data;
    TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
    if (data->ptr) {
      return data->ptr;
    } else {
      rb_raise(rb_eFiddleClearedReferenceError, "`ref` called on a cleared object");
    }
}
            
There is an updated format of the API docs for this version here.