Skip to content
Prev 31938 / 63424 Next

R thread safe

Duncan Temple Lang wrote (Mon Nov 7 22:35:22 CET 2005):
How is this going along?

For some things it would be simpler to use threads compared to
processes, to avoid the added complexity of passing the results back to
a master process.

With the emerging multicore processors it is essential that users can
easily make use of them.

A simple example of use:
  data1 <- data2 <- matrix(0, r, c)
  dataFiller <- function(i) {
   tmp <- someCalculation(i)
   data1[, i] <<- tmp$result1
   data2[, i] <<- tmp$result2
  }
  runParallelInThreads(1:c, dataFiller)

If this can be done almost as fast and simple with processes, for
instance using the multicore package, then I think it needs to be better
documented.