From b3e6d5cebdc2050b3fc1e685afd80831fda8e8ad Mon Sep 17 00:00:00 2001 From: Austin Wise Date: Mon, 27 Feb 2017 18:03:54 -0800 Subject: [PATCH] Remove CLRThreadpoolHosted as it always returns false. --- src/vm/threadpoolrequest.cpp | 16 +++++----------- src/vm/util.hpp | 6 ------ src/vm/win32threadpool.cpp | 21 ++++++--------------- src/vm/win32threadpool.h | 10 ++-------- 4 files changed, 13 insertions(+), 40 deletions(-) diff --git a/src/vm/threadpoolrequest.cpp b/src/vm/threadpoolrequest.cpp index 7dee1273bfc3..247deea304b3 100644 --- a/src/vm/threadpoolrequest.cpp +++ b/src/vm/threadpoolrequest.cpp @@ -368,11 +368,8 @@ void UnManagedPerAppDomainTPCount::SetAppDomainRequestsActive() LONG prevCount = FastInterlockCompareExchange(&m_outstandingThreadRequestCount, count+1, count); if (prevCount == count) { - if (!CLRThreadpoolHosted()) - { - ThreadpoolMgr::MaybeAddWorkingWorker(); - ThreadpoolMgr::EnsureGateThreadRunning(); - } + ThreadpoolMgr::MaybeAddWorkingWorker(); + ThreadpoolMgr::EnsureGateThreadRunning(); break; } count = prevCount; @@ -608,11 +605,8 @@ void ManagedPerAppDomainTPCount::SetAppDomainRequestsActive() LONG prev = FastInterlockCompareExchange(&m_numRequestsPending, count+1, count); if (prev == count) { - if (!CLRThreadpoolHosted()) - { - ThreadpoolMgr::MaybeAddWorkingWorker(); - ThreadpoolMgr::EnsureGateThreadRunning(); - } + ThreadpoolMgr::MaybeAddWorkingWorker(); + ThreadpoolMgr::EnsureGateThreadRunning(); break; } count = prev; @@ -688,7 +682,7 @@ void ManagedPerAppDomainTPCount::ClearAppDomainUnloading() // AD. // VolatileStore(&m_numRequestsPending, (LONG)ThreadpoolMgr::NumberOfProcessors); - if (!CLRThreadpoolHosted() && ThreadpoolMgr::IsInitialized()) + if (ThreadpoolMgr::IsInitialized()) { ThreadpoolMgr::MaybeAddWorkingWorker(); ThreadpoolMgr::EnsureGateThreadRunning(); diff --git a/src/vm/util.hpp b/src/vm/util.hpp index 6380460d64b6..f4fcc06cc0b4 100644 --- a/src/vm/util.hpp +++ b/src/vm/util.hpp @@ -708,12 +708,6 @@ inline BOOL CLRSyncHosted() return FALSE; } -inline BOOL CLRThreadpoolHosted() -{ - LIMITED_METHOD_CONTRACT; - return FALSE; -} - inline BOOL CLRIoCompletionHosted() { LIMITED_METHOD_CONTRACT; diff --git a/src/vm/win32threadpool.cpp b/src/vm/win32threadpool.cpp index ec42d5fbc232..a4b4ca9fe155 100644 --- a/src/vm/win32threadpool.cpp +++ b/src/vm/win32threadpool.cpp @@ -945,8 +945,6 @@ BOOL ThreadpoolMgr::QueueUserWorkItem(LPTHREAD_START_ROUTINE Function, bool ThreadpoolMgr::ShouldWorkerKeepRunning() { WRAPPER_NO_CONTRACT; - if (CLRThreadpoolHosted()) - return true; // // Maybe this thread should retire now. Let's see. @@ -1001,7 +999,6 @@ void ThreadpoolMgr::AdjustMaxWorkersActive() } CONTRACTL_END; - _ASSERTE(!CLRThreadpoolHosted()); _ASSERTE(ThreadAdjustmentLock.IsHeld()); DWORD currentTicks = GetTickCount(); @@ -1087,8 +1084,6 @@ void ThreadpoolMgr::MaybeAddWorkingWorker() } CONTRACTL_END; - _ASSERTE(!CLRThreadpoolHosted()); - // counts volatile read paired with CompareExchangeCounts loop set ThreadCounter::Counts counts = WorkerCounter.DangerousGetDirtyCounts(); ThreadCounter::Counts newCounts; @@ -1503,7 +1498,7 @@ void ThreadpoolMgr::EnsureGateThreadRunning() LIMITED_METHOD_CONTRACT; // The gate thread is only needed if the CLR is providing part of the ThreadPool implementation. - _ASSERTE(!CLRThreadpoolHosted() || !CLRIoCompletionHosted()); + _ASSERTE(!CLRIoCompletionHosted()); while (true) { @@ -1555,7 +1550,7 @@ bool ThreadpoolMgr::ShouldGateThreadKeepRunning() LIMITED_METHOD_CONTRACT; // The gate thread is only needed if the CLR is providing part of the ThreadPool implementation. - _ASSERTE(!CLRThreadpoolHosted() || !CLRIoCompletionHosted()); + _ASSERTE(!CLRIoCompletionHosted()); _ASSERTE(GateThreadStatus == GATE_THREAD_STATUS_WAITING_FOR_REQUEST || GateThreadStatus == GATE_THREAD_STATUS_REQUESTED); @@ -1584,8 +1579,7 @@ bool ThreadpoolMgr::ShouldGateThreadKeepRunning() // Are there any work requests in any worker queue? If so, we need a gate thread. // This imples that whenever a work queue goes from empty to non-empty, we need to call EnsureGateThreadRunning(). // - bool needGateThreadForWorkerThreads = - !CLRThreadpoolHosted() && + bool needGateThreadForWorkerThreads = PerAppDomainTPCountList::AreRequestsPendingInAnyAppDomains(); // @@ -2067,8 +2061,6 @@ DWORD __stdcall ThreadpoolMgr::WorkerThreadStart(LPVOID lpArgs) } CONTRACTL_END; - _ASSERTE(!CLRThreadpoolHosted()); - Thread *pThread = NULL; DWORD dwSwitchCount = 0; BOOL fThreadInit = FALSE; @@ -3334,7 +3326,7 @@ BOOL ThreadpoolMgr::CreateGateThread() LIMITED_METHOD_CONTRACT; // The gate thread is only needed if the CLR is providing part of the ThreadPool implementation. - _ASSERTE(!CLRThreadpoolHosted() || !CLRIoCompletionHosted()); + _ASSERTE(!CLRIoCompletionHosted()); HANDLE threadHandle = Thread::CreateUtilityThread(Thread::StackSize_Small, GateThreadStart, NULL); @@ -4305,7 +4297,7 @@ DWORD __stdcall ThreadpoolMgr::GateThreadStart(LPVOID lpArgs) CONTRACTL_END; // The gate thread is only needed if the CLR is providing part of the ThreadPool implementation. - _ASSERTE(!CLRThreadpoolHosted() || !CLRIoCompletionHosted()); + _ASSERTE(!CLRIoCompletionHosted()); _ASSERTE(GateThreadStatus == GATE_THREAD_STATUS_REQUESTED); @@ -4533,8 +4525,7 @@ DWORD __stdcall ThreadpoolMgr::GateThreadStart(LPVOID lpArgs) } #endif // !FEATURE_PAL - if (!CLRThreadpoolHosted() && - (0 == CLRConfig::GetConfigValue(CLRConfig::INTERNAL_ThreadPool_DisableStarvationDetection))) + if (0 == CLRConfig::GetConfigValue(CLRConfig::INTERNAL_ThreadPool_DisableStarvationDetection)) { if (PerAppDomainTPCountList::AreRequestsPendingInAnyAppDomains() && SufficientDelaySinceLastDequeue()) { diff --git a/src/vm/win32threadpool.h b/src/vm/win32threadpool.h index 13bca9f1e3aa..60758afd707f 100644 --- a/src/vm/win32threadpool.h +++ b/src/vm/win32threadpool.h @@ -1122,20 +1122,14 @@ class ThreadpoolMgr static void NotifyWorkItemCompleted() { WRAPPER_NO_CONTRACT; - if (!CLRThreadpoolHosted()) - { - Thread::IncrementThreadPoolCompletionCount(); - UpdateLastDequeueTime(); - } + Thread::IncrementThreadPoolCompletionCount(); + UpdateLastDequeueTime(); } static bool ShouldAdjustMaxWorkersActive() { WRAPPER_NO_CONTRACT; - if (CLRThreadpoolHosted()) - return false; - DWORD priorTime = PriorCompletedWorkRequestsTime; MemoryBarrier(); // read fresh value for NextCompletedWorkRequestsTime below DWORD requiredInterval = NextCompletedWorkRequestsTime - priorTime;