Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: src/utils/SkThreadUtils_pthread_linux.cpp

Issue 1408213005: Remove SkThread::setProcessorAffinity() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gAdds Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/utils/SkThreadUtils.h ('k') | src/utils/SkThreadUtils_pthread_mach.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 */
7
8 #ifndef _GNU_SOURCE
9 #define _GNU_SOURCE //for pthread_setaffinity_np
10 #endif
11
12 #include "SkThreadUtils.h"
13 #include "SkThreadUtils_pthread.h"
14
15 #include <pthread.h>
16
17 static int nth_set_cpu(unsigned int n, cpu_set_t* cpuSet) {
18 n %= CPU_COUNT(cpuSet);
19 for (unsigned int setCpusSeen = 0, currentCpu = 0; true; ++currentCpu) {
20 if (CPU_ISSET(currentCpu, cpuSet)) {
21 ++setCpusSeen;
22 if (setCpusSeen > n) {
23 return currentCpu;
24 }
25 }
26 }
27 }
28
29 bool SkThread::setProcessorAffinity(unsigned int processor) {
30 SkThread_PThreadData* pthreadData = static_cast<SkThread_PThreadData*>(fData );
31 if (!pthreadData->fValidPThread) {
32 return false;
33 }
34
35 cpu_set_t parentCpuset;
36 if (0 != pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &parentCp uset)) {
37 return false;
38 }
39
40 cpu_set_t cpuset;
41 CPU_ZERO(&cpuset);
42 CPU_SET(nth_set_cpu(processor, &parentCpuset), &cpuset);
43 return 0 == pthread_setaffinity_np(pthreadData->fPThread,
44 sizeof(cpu_set_t),
45 &cpuset);
46 }
OLDNEW
« no previous file with comments | « src/utils/SkThreadUtils.h ('k') | src/utils/SkThreadUtils_pthread_mach.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698