Skip to content
Prev 14597 / 21307 Next

[Bioc-devel] Rprintf in a multi-threaded environment

Thanks Martin and Luke, I think the only way to go is to only use the main thread to handle the screen output.

-----Original Message-----
From: Tierney, Luke <luke-tierney at uiowa.edu>
Sent: Wednesday, 30 January 2019 1:16 AM
To: Yang Liao <liao at wehi.edu.au>
Cc: bioc-devel at r-project.org
Subject: Re: [Bioc-devel] Rprintf in a multi-threaded environment

No functions in the R API are safe to call from any thread other than the R main thread.

-- Many may need to allocate from the R heap (more as ALTREP evaolves)
    and that is not thread safe;

-- Many (and with some compilation options nearly all) can signal an
    error, and the subsequent jump can only work in the main thread.

So: do not make R API calls from any thread other than the main thread. Ever.

[Separate processes as created by approaches in the parallel package
  do not have these issues, though simple forking as in multicore can
  have other issues as pointed out by Martin Morgan.]

Best,

luke
On Tue, 29 Jan 2019, Yang Liao wrote: