Skip to content

Child thread libR.so

1 message · Ryan C Metzger

#
Simon,
Ah, thank you! quiet right. For anyone searching for this in the
future, I changed my init fuction to:

---------- SNIP ----------------
void init_r() {
    SEXP aperm_function;

    /* this is our version of Rf_initEmbeddedR where we disable stack
checking */
    const char *init_argv[] = {"MyFront", "--vanilla", "--slave"};
    Rf_initialize_R(sizeof (init_argv) / sizeof (init_argv[0]),
(char**) init_argv);

    /* Disable stack limit checking since it is incompatible being
loaded on a child thread
     */
    R_CStackLimit = (uintptr_t)-1;

    R_Interactive = TRUE;  /* Rf_initialize_R set this based on isatty */
    setup_Rmainloop();
    /* end of Rf_initEmbeddedR */

    /*
     * transposeVector above uses the R builtin function aperm instead of
     * looking it up every time we need deal with transposing a multidimensional
     * intput/output look it up once here and save it off
     */
    aperm_function = findFun(install("aperm"), R_GlobalEnv);
    if (aperm_function == NULL || aperm_function == R_NilValue ||
aperm_function == R_UnboundValue) {
        aperm_function = NULL;
    } else {
        aperm_expression = PROTECT(allocVector(LANGSXP, 2));

        SETCAR(aperm_expression, aperm_function);
    }
}
---------- SNIP ----------------

This now behaves appropriately from a child thread in my custom front end.

thank you again Simon,
Ryan