@@ -1167,18 +1167,31 @@ private extern (D) bool suspend( Thread t ) nothrow @nogc
11671167 return false ;
11681168 }
11691169
1170- version (Windows )
1170+ const sameThread = t.m_addr == gettid();
1171+
1172+ if (! sameThread)
11711173 {
1172- if ( t.m_addr != gettid() && ! suspendThreadImpl( t ) )
1174+ if (! suspendThreadImpl(t) )
11731175 {
1174- if ( ! t.isRunning )
1176+ if (t.isRunning)
1177+ onThreadError( " Unable to suspend thread" );
1178+ else
11751179 {
11761180 Thread .remove( t );
11771181 return false ;
11781182 }
1179- onThreadError( " Unable to suspend thread" );
11801183 }
1184+ }
11811185
1186+ loadStackAndRegInfo(t, sameThread);
1187+
1188+ return true ;
1189+ }
1190+
1191+ private void loadStackAndRegInfo (Thread t, const bool sameThread) nothrow @nogc
1192+ {
1193+ version (Windows )
1194+ {
11821195 CONTEXT context = void ;
11831196 context.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL ;
11841197
@@ -1228,16 +1241,6 @@ private extern (D) bool suspend( Thread t ) nothrow @nogc
12281241 }
12291242 else version (Darwin)
12301243 {
1231- if ( t.m_addr != gettid() && ! suspendThreadImpl( t ) )
1232- {
1233- if ( ! t.isRunning )
1234- {
1235- Thread .remove( t );
1236- return false ;
1237- }
1238- onThreadError( " Unable to suspend thread" );
1239- }
1240-
12411244 version (X86 )
12421245 {
12431246 x86_thread_state32_t state = void ;
@@ -1353,18 +1356,8 @@ private extern (D) bool suspend( Thread t ) nothrow @nogc
13531356 }
13541357 else version (Solaris )
13551358 {
1356- if (t.m_addr != gettid() )
1359+ if (! sameThread )
13571360 {
1358- if (! suspendThreadImpl(t))
1359- {
1360- if (! t.isRunning)
1361- {
1362- Thread .remove(t);
1363- return false ;
1364- }
1365- onThreadError(" Unable to suspend thread" );
1366- }
1367-
13681361 static int getLwpStatus (ulong lwpid, out lwpstatus_t status)
13691362 {
13701363 import core.sys.posix.fcntl : open, O_RDONLY ;
@@ -1490,30 +1483,11 @@ private extern (D) bool suspend( Thread t ) nothrow @nogc
14901483 }
14911484 else version (Posix )
14921485 {
1493- if ( t.m_addr != gettid() )
1494- {
1495- if ( ! suspendThreadImpl( t ) )
1496- {
1497- if ( ! t.isRunning )
1498- {
1499- Thread .remove( t );
1500- return false ;
1501- }
1502- onThreadError( " Unable to suspend thread" );
1503- }
1504- }
1505- else if ( ! t.m_lock )
1486+ if (sameThread && ! t.m_lock)
15061487 {
15071488 t.m_curr.tstack = getStackTop();
15081489 }
15091490 }
1510- else version (WASI )
1511- {
1512- onThreadError( " Unable to suspend thread" );
1513- }
1514- else
1515- static assert (0 , " unsupported os" );
1516- return true ;
15171491}
15181492
15191493/**
0 commit comments