diff options
author | 2012-05-14 14:09:24 +0000 | |
---|---|---|
committer | 2012-05-14 14:09:24 +0000 | |
commit | 554875210043b34178f7ed6ac5bd682b1fad367b (patch) | |
tree | fdadeb167ef502f98784117a3c05378c72fceeec /src/utils/SkThreadUtils_pthread_mach.cpp | |
parent | f105b109264f71dfb0bfd9977e6a5dd0a5a12f57 (diff) |
Add bench and test for SkRefCnt.
http://codereview.appspot.com/6195071/
This also adds a cross platform SkThread for testing purposes.
git-svn-id: http://skia.googlecode.com/svn/trunk@3921 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/SkThreadUtils_pthread_mach.cpp')
-rw-r--r-- | src/utils/SkThreadUtils_pthread_mach.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/utils/SkThreadUtils_pthread_mach.cpp b/src/utils/SkThreadUtils_pthread_mach.cpp new file mode 100644 index 0000000000..0f6e263906 --- /dev/null +++ b/src/utils/SkThreadUtils_pthread_mach.cpp @@ -0,0 +1,30 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkThreadUtils.h" +#include "SkThreadUtils_pthread.h" + +#include <mach/mach.h> +#include <mach/thread_policy.h> +#include <pthread.h> + +bool SkThread::setProcessorAffinity(unsigned int processor) { + SkThread_PThreadData* pthreadData = static_cast<SkThread_PThreadData*>(fData); + if (!pthreadData->fValidPThread) { + return false; + } + + mach_port_t tid = pthread_mach_thread_np(pthreadData->fPThread); + + thread_affinity_policy_data_t policy; + policy.affinity_tag = processor; + + return 0 == thread_policy_set(tid, + THREAD_AFFINITY_POLICY, + (thread_policy_t) &policy, + THREAD_AFFINITY_POLICY_COUNT); +} |