[Rcpp-devel] Thread handling

Dirk Eddelbuettel edd at debian.org
Wed Apr 27 06:51:19 CEST 2011

On 26 April 2011 at 21:41, Steve Lianoglou wrote:
| We kind of lost context of the original post, but:

Did we?
| On Tue, Apr 26, 2011 at 8:19 PM, Christian Gunning <xian at unm.edu> wrote:
| Just to clarify the original intent -- the impression I got from the
| OP is that he actually wanted to fire off a thread to run in the
| background and have the user continue to use R while the background
| process finishes, so ... he doesn't want R to wait for it to return.
| I'm not an R-internals/plumbing guru, but if I had to guess, I'd say
| that this is an "out of bounds" use case and I'm guessing will be
| painful (impossible(?)) to get working as the OP intended ... I'd be
| happy to be proven wrong, though.
| I'm not sure what a suitable workaround would be -- I wonder if the
| C(++) code you call down into can spawn a thread that then uses
| RInside to fire up its own R process, configure it w/ the appropriate
| vars/data, run the job in that single threaded R and just save the
| results to some predertimed data file (not sure if that's the right
| use case for RInside, either, I'm guessing) -- all the while control
| will be returned to the users running R workspace.
| At that point, though, maybe you'd just make a command line wrapper to
| run your job from the shell and forget about invoking background
| processes from within R altogether.
| Just thinking out loud ..

Christian actually put it well:

a) R is single-threaded

b) You can leave R and start multi-threaded code at a well defined entry

c) You can do your multithreaded work. I would recommend not to call R at
this point.

d) When done with multithreaded code, return to R and its control flow there.

That is a simple model, and it should work. 

| -steve
| -- 
| Steve Lianoglou
| Graduate Student: Computational Systems Biology
|  | Memorial Sloan-Kettering Cancer Center
|  | Weill Medical College of Cornell University
| Contact Info: http://cbio.mskcc.org/~lianos/contact
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com

More information about the Rcpp-devel mailing list