Skip to content
Prev 10675 / 15075 Next

Embedded R, event loops, GUI events, and OS X

Hi Simon,

Thanks for the reply.  I?m looking into giving you access to the H repository.  Meanwhile, this is how we initialise embedded R, disabling stack limit checks:

    // NOTE: It is crucial to set the two R stack globals after calling
    // Rf_initialize_R() and before calling setup_Rmainloop().
    // H_initUnlimitedEmbeddedR() is based on Rf_initEmbeddedR(), found in
    // R 3.1.0 source code at src/gnuwin32/embeddedR.c:127.
    int H_initUnlimitedEmbeddedR(int argc, char **argv)
    {
        Rf_initialize_R(argc, argv);
        R_CStackLimit = -1;
        R_CStackStart = -1;
        setup_Rmainloop();
        return(1);
    }

We do use our own event loop.  In order to mesh the H loop and the R loop, we do two things every 0.03 seconds, depending on the platform, neither of which fixes the issue on OS X:

1. On Linux, we call the following:

    void processGUIEventsUnix(InputHandler** inputHandlers) {
      if (*inputHandlers == NULL)
          initStdinHandler();
      R_runHandlers(*inputHandlers, R_checkActivityEx(1000, 0, NULL));
    }

2. On Windows, we call `R_ProcessEvents`.

Can you say what exactly you have in mind when you say ?run the R event loop??

Best,