void BackgroundJobProcessor::DissociatePageAllocator(PageAllocator* const pageAllocator) { // This function is called from the foreground thread #if DBG // Assert that the dissociation is happening in the same thread that created the background job processor Assert(GetCurrentThreadContextId() == this->threadId); pageAllocator->ClearConcurrentThreadId(); #endif }
StringProfiler::StringProfiler(PageAllocator * pageAllocator) : allocator(L"StringProfiler", pageAllocator, Throw::OutOfMemory ), mainThreadId(GetCurrentThreadContextId() ), discardedWrongThread(0), stringLengthMetrics(&allocator), embeddedNULChars(0), embeddedNULStrings(0), emptyStrings(0), singleCharStrings(0), stringConcatMetrics(&allocator, 43) { }
BackgroundJobProcessor::BackgroundJobProcessor(AllocationPolicyManager* policyManager, JsUtil::ThreadService *threadService, bool disableParallelThreads) : JobProcessor(true), jobReady(true), wakeAllBackgroundThreads(false), numJobs(0), threadId(GetCurrentThreadContextId()), threadService(threadService), threadCount(0), maxThreadCount(0) { if (!threadService->HasCallback()) { // We don't have a thread service, so create a dedicated thread to handle background jobs. InitializeParallelThreadData(policyManager, disableParallelThreads); } else { InitializeParallelThreadDataForThreadServiceCallBack(policyManager); } }
bool StringProfiler::IsOnWrongThread() const { return GetCurrentThreadContextId() != this->mainThreadId; }