@@ -3703,82 +3703,6 @@ void Thread::UserInterrupt(ThreadInterruptMode mode)
37033703 }
37043704}
37053705
3706- // Implementation of Thread.Sleep().
3707- void Thread::UserSleep (INT32 time)
3708- {
3709- CONTRACTL {
3710- THROWS;
3711- GC_TRIGGERS;
3712- }
3713- CONTRACTL_END;
3714-
3715- INCONTRACT (_ASSERTE (!GetThread ()->GCNoTrigger ()));
3716-
3717- DWORD res;
3718-
3719- // Before going to pre-emptive mode the thread needs to be flagged as waiting for
3720- // the debugger. This used to be accomplished by the TS_Interruptible flag but that
3721- // doesn't work reliably, see DevDiv Bugs 699245.
3722- ThreadStateNCStackHolder tsNC (TRUE , TSNC_DebuggerSleepWaitJoin);
3723- GCX_PREEMP ();
3724-
3725- // A word about ordering for Interrupt. If someone tries to interrupt a thread
3726- // that's in the interruptible state, we queue an APC. But if they try to interrupt
3727- // a thread that's not in the interruptible state, we just record that fact. So
3728- // we have to set TS_Interruptible before we test to see whether someone wants to
3729- // interrupt us or else we have a race condition that causes us to skip the APC.
3730- SetThreadState (TS_Interruptible);
3731-
3732- // If someone has interrupted us, we should not enter the wait.
3733- if (IsUserInterrupted ())
3734- {
3735- HandleThreadInterrupt ();
3736- }
3737-
3738- ThreadStateHolder tsh (TRUE , TS_Interruptible | TS_Interrupted);
3739-
3740- ResetThreadState (TS_Interrupted);
3741-
3742- DWORD dwTime = (DWORD)time;
3743- retry:
3744-
3745- ULONGLONG start = minipal_lowres_ticks ();
3746-
3747- res = ClrSleepEx (dwTime, TRUE );
3748-
3749- if (res == WAIT_IO_COMPLETION)
3750- {
3751- // We could be woken by some spurious APC or an EE APC queued to
3752- // interrupt us. In the latter case the TS_Interrupted bit will be set
3753- // in the thread state bits. Otherwise we just go back to sleep again.
3754- if ((m_State & TS_Interrupted))
3755- {
3756- HandleThreadInterrupt ();
3757- }
3758-
3759- if (dwTime == INFINITE)
3760- {
3761- goto retry;
3762- }
3763- else
3764- {
3765- ULONGLONG actDuration = minipal_lowres_ticks () - start;
3766-
3767- if (dwTime > actDuration)
3768- {
3769- dwTime -= (DWORD)actDuration;
3770- goto retry;
3771- }
3772- else
3773- {
3774- res = WAIT_TIMEOUT;
3775- }
3776- }
3777- }
3778- _ASSERTE (res == WAIT_TIMEOUT || res == WAIT_OBJECT_0);
3779- }
3780-
3781-
37823706// Correspondence between an EE Thread and an exposed System.Thread:
37833707OBJECTREF Thread::GetExposedObject ()
37843708{
0 commit comments