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

Commit

Permalink
reverted one change that should have been unnecessary, comments inlin…
Browse files Browse the repository at this point in the history
…e about why
  • Loading branch information
complexmath committed May 16, 2011
1 parent d92dabe commit 5098e60
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/core/thread.d
Expand Up @@ -681,7 +681,7 @@ class Thread
}
body
{
this(); // set m_tls
this();
m_fn = fn;
m_sz = sz;
m_call = Call.FN;
Expand All @@ -707,7 +707,7 @@ class Thread
}
body
{
this(); // set m_tls
this();
m_dg = dg;
m_sz = sz;
m_call = Call.DG;
Expand Down Expand Up @@ -793,17 +793,7 @@ class Thread
// starting thread. In effect, not doing the add here risks
// having thread being treated like a daemon thread.
synchronized( slock )
{
// when creating threads from inside a DLL, DllMain(THREAD_ATTACH)
// might be called before _beginthreadex returns, but the dll
// helper functions need to know whether the thread is created
// from the runtime itself or from another DLL or the application
// to just attach to it
// as the consequence, the new Thread object is added before actual
// creation of the thread. There should be no problem with the GC
// calling thread_suspendAll, because of the slock synchronization
add( this );

{
version( Windows )
{
m_hndl = cast(HANDLE) _beginthreadex( null, m_sz, &thread_entryPoint, cast(void*) this, 0, &m_addr );
Expand All @@ -827,6 +817,15 @@ class Thread
if( m_tmach == m_tmach.init )
throw new ThreadException( "Error creating thread" );
}
// NOTE: DllMain(THREAD_ATTACH) may be called before this call
// exits, and this in turn calls thread_findByAddr, which
// would expect this thread to be in the global list if it
// is a D-created thread. However, since thread_findByAddr
// acquires Thread.slock before searching the list, it is
// safe to add this thread after _beginthreadex instead
// of before. This also saves us from having to use a
// scope statement to remove the thread on error.
add( this );
}
}

Expand Down

0 comments on commit 5098e60

Please sign in to comment.