gfx/skia/trunk/src/utils/SkThreadUtils_pthread_mach.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*
     2  * Copyright 2012 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #include "SkThreadUtils.h"
     9 #include "SkThreadUtils_pthread.h"
    11 #include <mach/mach.h>
    12 #include <mach/thread_policy.h>
    13 #include <pthread.h>
    15 bool SkThread::setProcessorAffinity(unsigned int processor) {
    16     SkThread_PThreadData* pthreadData = static_cast<SkThread_PThreadData*>(fData);
    17     if (!pthreadData->fValidPThread) {
    18         return false;
    19     }
    21     mach_port_t tid = pthread_mach_thread_np(pthreadData->fPThread);
    23     thread_affinity_policy_data_t policy;
    24     policy.affinity_tag = processor;
    26     return 0 == thread_policy_set(tid,
    27                                   THREAD_AFFINITY_POLICY,
    28                                   (thread_policy_t) &policy,
    29                                   THREAD_AFFINITY_POLICY_COUNT);
    30 }

mercurial