michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #include "SkThreadUtils.h" michael@0: #include "SkThreadUtils_pthread.h" michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: bool SkThread::setProcessorAffinity(unsigned int processor) { michael@0: SkThread_PThreadData* pthreadData = static_cast(fData); michael@0: if (!pthreadData->fValidPThread) { michael@0: return false; michael@0: } michael@0: michael@0: mach_port_t tid = pthread_mach_thread_np(pthreadData->fPThread); michael@0: michael@0: thread_affinity_policy_data_t policy; michael@0: policy.affinity_tag = processor; michael@0: michael@0: return 0 == thread_policy_set(tid, michael@0: THREAD_AFFINITY_POLICY, michael@0: (thread_policy_t) &policy, michael@0: THREAD_AFFINITY_POLICY_COUNT); michael@0: }