Hi, I?ve finally got a working start to using Rcpp to interface with some of my c++ code, and now I have a practical question about the interface. My first task was simply to launch algorithms from R, and thanks to a lot of help from this community, I finally got that task solved. Now, however, I lose all response from R as soon as I launch many long and intensive algorithms. That isn?t to say it isn?t working, and the responsiveness comes back after the jobs eventually finish. Ideally, I would like to let my users continue to use R while their jobs run, and I can handle that in c++ with threads. However, I also want to let my users know when their jobs finish. Ordinarily I would register some sort of callback function in one of my own programs to alert a user when a threaded task finishes. However, I don?t know enough about R to know how to send a message to a user, especially from external code that has been called. As is, I?m able to return an argument such as a SEXP value from my function, and I can have it give feedback. However, if I do that before the thread finishes, I don?t know if there is a way to access it any more after the thread finishes. Likewise, if I were to wait until the thread finishes, then I might as well not call a thread. So what would be recommended as an Rcpp suggested mechanism for alerting users in R as to when threaded jobs finish? Thanks, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110426/812bf806/attachment-0001.htm>
[Rcpp-devel] Thread handling
2 messages · Sean Robert McGuffee, Dirk Eddelbuettel
On 26 April 2011 at 14:46, Sean Robert McGuffee wrote:
| Hi, | I?ve finally got a working start to using Rcpp to interface with some of my c++ | code, and now I have a practical question about the interface. My first task | was simply to launch algorithms from R, and thanks to a lot of help from this | community, I finally got that task solved. Now, however, I lose all response | from R as soon as I launch many long and intensive algorithms. That isn?t to | say it isn?t working, and the responsiveness comes back after the jobs | eventually finish. Ideally, I would like to let my users continue to use R | while their jobs run, and I can handle that in c++ with threads. However, I | also want to let my users know when their jobs finish. Ordinarily I would | register some sort of callback function in one of my own programs to alert a | user when a threaded task finishes. However, I don?t know enough about R to | know how to send a message to a user, especially from external code that has | been called. As is, I?m able to return an argument such as a SEXP value from my | function, and I can have it give feedback. However, if I do that before the | thread finishes, I don?t know if there is a way to access it any more after the | thread finishes. Likewise, if I were to wait until the thread finishes, then I | might as well not call a thread. So what would be recommended as an Rcpp | suggested mechanism for alerting users in R as to when threaded jobs finish? Sorry that I keep repeating myself to you, but you may want to look at the r-devel list which featured a series of posts (a "thread" ;-) under the subject header "Interrupting C++ code execution" discussing just that. You should also realize that R is inherently single-threaded. Dirk
Gauss once played himself in a zero-sum game and won $50.
-- #11 at http://www.gaussfacts.com