[m-users.] What is "thread-local storage"?
Volker Wysk
post at volker-wysk.de
Sat Dec 16 01:18:33 AEDT 2023
Am Freitag, dem 15.12.2023 um 23:57 +1100 schrieb Julien Fischer:
> On Fri, 15 Dec 2023, Volker Wysk wrote:
>
> > In mercury_memory.h, there's this:
> >
> > // MR_GC_NEW(type):
> > // Allocates space for an object of the specified type.
> > // If conservative GC is enabled, the object will be garbage collected
> > // when it is no longer referenced from GC-traced memory.
> > // Memory allocated with malloc() (or MR_malloc() or MR_NEW())
> > // is not GC-traced. Nor is thread-local storage.
> >
> > I don't understand the "Nor is thread-local storage." part. What is
> > "thread-local storage"?
>
> In this context it can refer to values stored using the POSIX threads
> function pthread_setspecific(), or to variables declared using GCC's
> __thread keyword or C11's _Thread_local keyword.
Okay. The documentation for that made it clear, what it is.
> > Do I need to care?
>
> I can't answer that; I don't know what you are trying to do.
I'm trying to avoid messing with MMC internals, if possible. I was wondering
if I have to deal with that thread-local storage, when I use MR_GC_NEW() in
a multi-threaded program. I take your answer for a "no".
I'm in the second approach to build a thread-safe ODBC library (derived from
the ODBC "extra" library).
Cheers,
Volker
More information about the users
mailing list