Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Use generic TLS instead of pthread_specific/TlsAlloc
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNowak committed May 29, 2011
1 parent 0cbf6da commit 58720d7
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions src/core/thread.d
Expand Up @@ -3310,18 +3310,11 @@ class Fiber
*
* Returns:
* The fiber object representing the calling fiber or null if no fiber
* is currently active. The result of deleting this object is undefined.
* is currently active within this thread. The result of deleting this object is undefined.
*/
static Fiber getThis()
{
version( Windows )
{
return cast(Fiber) TlsGetValue( sm_this );
}
else version( Posix )
{
return cast(Fiber) pthread_getspecific( sm_this );
}
return sm_this;
}


Expand All @@ -3330,24 +3323,6 @@ class Fiber
///////////////////////////////////////////////////////////////////////////


shared static this()
{
version( Windows )
{
sm_this = TlsAlloc();
assert( sm_this != TLS_OUT_OF_INDEXES );
}
else version( Posix )
{
int status;

status = pthread_key_create( &sm_this, null );
assert( status == 0 );

}
}


version( Posix )
{
static this()
Expand Down Expand Up @@ -3716,18 +3691,10 @@ private:
//
static void setThis( Fiber f )
{
version( Windows )
{
TlsSetValue( sm_this, cast(void*) f );
}
else version( Posix )
{
pthread_setspecific( sm_this, cast(void*) f );
}
sm_this = f;
}


__gshared Thread.TLSKey sm_this;
static Fiber sm_this;


private:
Expand Down

0 comments on commit 58720d7

Please sign in to comment.