Thread Local Storage Template
Stewart Gordon
smjg_1998 at yahoo.com
Tue Sep 12 03:53:07 PDT 2006
Mikola Lysenko wrote:
> The current version of D does not have thread local storage. This is a
> very useful feature, and the lack of support is frustrating. The
> problem is compounded by the fact that there are no truly cross platform
> thread local storage facilities. To work around this problem, I have
> created a simple templatized wrapper. It currently supports DMD and GDC
> on the following platforms:
>
> Windows
> Linux
> Mac OS X
>
> You can download it at: http://www.assertfalse.com/projects.shtml
I figured out what it was doing after a while. So it provides access to
a per-thread data store that only the associated thread can access,
without having to go through a Thread object to get to it.
At first I thought that tls_key was some per-thread key, but then I
realised it's a key related to the ThreadLocal object. So you can use
more than one ThreadLocal at the same time.
I can see that this idea in itself might have some practical uses, I'm
just trying to think what they are....
Is there a particular reason that the whole code is duplicated between
TLS_UsePthreads and TLS_UseWinAPI, rather than versioning only what's
different?
Stewart.
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:-@ C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS-
PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y
------END GEEK CODE BLOCK------
My e-mail is valid but not my primary mailbox. Please keep replies on
the 'group where everyone may benefit.
More information about the Digitalmars-d-announce
mailing list