From g@bembecker @end|ng |rom gm@||@com  Mon Sep 14 00:08:26 2020
From: g@bembecker @end|ng |rom gm@||@com (Gabriel Becker)
Date: Sun, 13 Sep 2020 15:08:26 -0700
Subject: [Rd] [External] Thread-safe R functions
In-Reply-To: <alpine.DEB.2.21.2009130844520.3141@luke-Latitude-7480>
References: <CAGiFhPOH1ky6fSJ-J23hMD815KvMXWaNifgrhHVsd=+svS1VFA-8789@mail.gmail.com>
 <alpine.DEB.2.21.2009130844520.3141@luke-Latitude-7480>
Message-ID: <CAD4oTHGfLELbLURwfWJiFZBe+mAEVsowQwme7vVD=xBOWE111Q@mail.gmail.com>

Jiefei,

Beyond the general response that Luke gave, to be a bit more specific to
what you said, DATAPTR and INTEGER_GET_REGION involve ALTREP method
execution (for ALTREP objects, obviously) so even they are not as simple
and straightforward as they were a couple years ago. They should not (any
longer) be thought of as being guaranteed to be essentially bare metal data
retrieval from memory.

Best,
~G

On Sun, Sep 13, 2020 at 6:49 AM <luke-tierney at uiowa.edu> wrote:

> 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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



[Rd] [External] Thread-safe R functions
Gabriel Becker