<div dir="ltr"><div>Thanks. This is all happening inside a package for CRAN, so I would rather avoid more complexity and potential platform-dependence, but I also cannot afford for it to break unpredictably (or otherwise).<br></div>Murray<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 16, 2018 at 3:33 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On 16 April 2018 at 13:41, Murray Efford wrote:<br>
| I read in the RcppParallel blurb "The code that you write within parallel<br>
| workers should not call the R or Rcpp API in any fashion", which is<br>
| admirably clear. However, it leaves me without threadsafe access to<br>
| distribution functions (dpois, dbinom etc.). In practice, so far, these R<br>
| API calls seem to work for me, but can they be trusted? Is there an<br>
| alternative?<br>
<br>
</span>That's a fair question. They may work, as they are also exposed / available<br>
via the standalone R math library (see Writing R Extensions).<br>
<br>
As such, they may not required memory allocations or other interactions with<br>
the R process and hence "not call R ... in any fashion" per the above. <br>
<br>
But we can't say for sure. If you want to be safe, maybe stick to <br>
equivalent functions from a non-R source: C++11, Boost, ...  <br>
<br>
Dirk<br>
<div class="HOEnZb"><div class="h5"><br>
| (It seems this question must have arisen before, but I haven't found an<br>
| answer)<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">-- <br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
</font></span></blockquote></div><br></div>