I am calling a C function from R using .C. This is a simulation which will run for a few minutes, and every few iterations, I would like to send some information of the progress to R. That is, I do not want to wait till the C function finishes to send all the info at once to R.
Note: I do not want to PRINT in R (Rprintf does that). But I want to pass such info to R. Also using error passes the error to R if R.h is included, but I am not interested in exception handling.
My first direction:
I use futile.logger in R to log such stuff. Preferably, if such information can be passed to the same logger that the calling R function is using, would be great. But I could not find any examples on the web.
Alternative direction: I am also using redis to write information in cache, which are then consumed by others that connect to the redis db. But I don't find any C interface to redis. I do NOT want to use Lua. The closest I have found is Writing a Custom Redis Command In C - Part 2.
But my needs are far simpler in my opinion. Any ideas?
Update: This is how I am hoping this will work ideally.
# PART 1: webserver calls R function
# the R call
res = .C("montecarlo_sampler.c", as.matrix(inputData), as.matrix(ouputData), as.integer(iterations))
// PART 2: the C function
void montecarlo_sampler( double *inputData, double *outputData, int *iterations){
  // do some preprocessing
  int iter =1;
  while(iter<1000000){
    if(iter % 1000 == 0) {
      // summarize output from last 1000 iterations
      // dump summary data to a logger or redis
    }
    // do usual sampling stuff in C
  }
}
PART 3:
// listening on the django side
// polls redis every few seconds to see if update has reached.
// sends summary output for visualization to client
 
    