From iuke-tier@ey m@iii@g oii uiow@@edu  Sun Sep 13 15:48:49 2020
From: iuke-tier@ey m@iii@g oii uiow@@edu (iuke-tier@ey m@iii@g oii uiow@@edu)
Date: Sun, 13 Sep 2020 08:48:49 -0500 (CDT)
Subject: [Rd] [External]  Thread-safe R functions
In-Reply-To: <CAGiFhPOH1ky6fSJ-J23hMD815KvMXWaNifgrhHVsd=+svS1VFA-8789@mail.gmail.com>
References: <CAGiFhPOH1ky6fSJ-J23hMD815KvMXWaNifgrhHVsd=+svS1VFA-8789@mail.gmail.com>
Message-ID: <alpine.DEB.2.21.2009130844520.3141@luke-Latitude-7480>

You should assume that NO functions or macros in the R API are
thread-safe.  If some happen to be now, on some platforms, they are
not guaranteed to be in the future. Even if you use a global lock you
need to keep in mind that any function in the R API can signal an
error and execute a longjmp, so you need to make sure you have set a
top level context in your thread.

Best,

luke

On Sun, 13 Sep 2020, Jiefei Wang wrote:

> Hi,
>
> I am curious about whether there exist thread-safe functions in
> `Rinternals.h`.  I know that R is single-threaded designed, but for the
> simple and straightforward functions like `DATAPTR` and `INTEGER_GET_REGION`,
> are these functions safe to call in a multi-thread environment?
>
> Best,
> Jiefei
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] [External] Thread-safe R functions
iuke-tier@ey m@iii@g oii uiow@@edu