Ignore:
Timestamp:
Mar 24, 2014, 12:25:32 PM (11 years ago)
Author:
[email protected]
Message:

Add support for thread QoS
https://bugs.webkit.org/show_bug.cgi?id=130688

Reviewed by Andreas Kling.

Source/JavaScriptCore:

  • heap/BlockAllocator.cpp:

(JSC::BlockAllocator::blockFreeingThreadStartFunc):

  • block freeing is a utility activity.

Source/WTF:

  • wtf/FastMalloc.cpp:

(WTF::TCMalloc_PageHeap::runScavengerThread):

  • block freeing is a utility activity.
  • wtf/Threading.h:
    • declaration.
  • wtf/ThreadingPthreads.cpp:

(WTF::createThreadInternal):

  • default to interactive.

(WTF::setCurrentThreadQOSUtility):

  • implementation.
  • wtf/ThreadingWin.cpp:

(WTF::setCurrentThreadQOSUtility):

  • no-op implementation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/wtf/ThreadingPthreads.cpp

    r165691 r166184  
    174174    auto invocation = std::make_unique<ThreadFunctionInvocation>(entryPoint, data);
    175175    pthread_t threadHandle;
    176     if (pthread_create(&threadHandle, 0, wtfThreadEntryPoint, invocation.get())) {
     176    pthread_attr_t attr;
     177    pthread_attr_init(&attr);
     178#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     179    pthread_attr_set_qos_class_np(&attr, QOS_CLASS_USER_INTERACTIVE, 0);
     180#endif
     181    int error = pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, invocation.get());
     182    pthread_attr_destroy(&attr);
     183
     184    if (error) {
    177185        LOG_ERROR("Failed to create pthread at entry point %p with data %p", wtfThreadEntryPoint, invocation.get());
    178186        return 0;
     
    226234    pthread_setschedparam(pthreadHandle, policy, &param);
    227235}
    228    
     236
     237void setCurrentThreadQOSUtility()
     238{
     239#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     240    pthread_set_qos_class_np(pthread_self(), QOS_CLASS_UTILITY, 0);
     241#endif
     242}
     243
    229244int waitForThreadCompletion(ThreadIdentifier threadID)
    230245{
Note: See TracChangeset for help on using the changeset viewer.