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

Commit 7a731ff

Browse files
committed
add the Thread after errors are handled
- would have ended up with a stale Thread entry - Thread list access is slock synchronized so it makes no difference when we add it
1 parent 43525e9 commit 7a731ff

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/core/thread.d

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -828,18 +828,6 @@ class Thread
828828
// having thread being treated like a daemon thread.
829829
synchronized( slock )
830830
{
831-
// NOTE: when creating threads from inside a DLL, DllMain(THREAD_ATTACH)
832-
// might be called before ResumeThread returns, but the dll
833-
// helper functions need to know whether the thread is created
834-
// from the runtime itself or from another DLL or the application
835-
// to just attach to it
836-
// as a consequence, the new Thread object is added before actual
837-
// creation of the thread. There should be no problem with the GC
838-
// calling thread_suspendAll, because of the slock synchronization
839-
//
840-
// VERIFY: does this actually also apply to other platforms?
841-
add( this );
842-
843831
version( Windows )
844832
{
845833
if( ResumeThread( m_hndl ) == -1 )
@@ -862,6 +850,18 @@ class Thread
862850
if( m_tmach == m_tmach.init )
863851
throw new ThreadException( "Error creating thread" );
864852
}
853+
854+
// NOTE: when creating threads from inside a DLL, DllMain(THREAD_ATTACH)
855+
// might be called before ResumeThread returns, but the dll
856+
// helper functions need to know whether the thread is created
857+
// from the runtime itself or from another DLL or the application
858+
// to just attach to it
859+
// as a consequence, the new Thread object is added before actual
860+
// creation of the thread. There should be no problem with the GC
861+
// calling thread_suspendAll, because of the slock synchronization
862+
//
863+
// VERIFY: does this actually also apply to other platforms?
864+
add( this );
865865
}
866866
}
867867

0 commit comments

Comments
 (0)