RObjectStorage

Enables reference counting of objects allocated by R. It takes care of protecting and unprotecting objects from the R garbage collector.

R objects allocated inside R and passed to D are automatically protected. Attempting to protect/unprotect them will result in an error. R objects allocated by D have to be protected from the garbage collector while they are active, and unprotected when you are done with them.

This is an implementation of the reference counting scheme in Adam Ruppe's D Cookbook.

This does not do anything to protect an R object. ProtectedRObject holds an object that has already been protected and unprotects it when there are no more references to it.
  1. struct RObjectStorage
    private
    struct RObjectStorage {}
  2. struct ProtectedRObject

Members

Variables

ptr
Robj ptr;

The Robj struct to be protected

refcount
int refcount;

The number of active references to ptr.

unprotect
bool unprotect;

A flag indicating that the object needs to be unprotected when there are no more references to it. Set to false if working with data that was allocated in R and passed to D.

Meta