OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ipc/ipc_perftest_support.h" | 5 #include "ipc/ipc_perftest_support.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 return 0; | 341 return 0; |
342 } | 342 } |
343 | 343 |
344 scoped_refptr<base::TaskRunner> PingPongTestClient::task_runner() { | 344 scoped_refptr<base::TaskRunner> PingPongTestClient::task_runner() { |
345 return main_message_loop_.task_runner(); | 345 return main_message_loop_.task_runner(); |
346 } | 346 } |
347 | 347 |
348 LockThreadAffinity::LockThreadAffinity(int cpu_number) | 348 LockThreadAffinity::LockThreadAffinity(int cpu_number) |
349 : affinity_set_ok_(false) { | 349 : affinity_set_ok_(false) { |
350 #if defined(OS_WIN) | 350 #if defined(OS_WIN) |
351 const DWORD_PTR thread_mask = 1 << cpu_number; | 351 const DWORD_PTR thread_mask = static_cast<DWORD_PTR>(1) << cpu_number; |
352 old_affinity_ = SetThreadAffinityMask(GetCurrentThread(), thread_mask); | 352 old_affinity_ = SetThreadAffinityMask(GetCurrentThread(), thread_mask); |
353 affinity_set_ok_ = old_affinity_ != 0; | 353 affinity_set_ok_ = old_affinity_ != 0; |
354 #elif defined(OS_LINUX) | 354 #elif defined(OS_LINUX) |
355 cpu_set_t cpuset; | 355 cpu_set_t cpuset; |
356 CPU_ZERO(&cpuset); | 356 CPU_ZERO(&cpuset); |
357 CPU_SET(cpu_number, &cpuset); | 357 CPU_SET(cpu_number, &cpuset); |
358 auto get_result = sched_getaffinity(0, sizeof(old_cpuset_), &old_cpuset_); | 358 auto get_result = sched_getaffinity(0, sizeof(old_cpuset_), &old_cpuset_); |
359 DCHECK_EQ(0, get_result); | 359 DCHECK_EQ(0, get_result); |
360 auto set_result = sched_setaffinity(0, sizeof(cpuset), &cpuset); | 360 auto set_result = sched_setaffinity(0, sizeof(cpuset), &cpuset); |
361 // Check for get_result failure, even though it should always succeed. | 361 // Check for get_result failure, even though it should always succeed. |
(...skipping 10 matching lines...) Expand all Loading... |
372 auto set_result = SetThreadAffinityMask(GetCurrentThread(), old_affinity_); | 372 auto set_result = SetThreadAffinityMask(GetCurrentThread(), old_affinity_); |
373 DCHECK_NE(0u, set_result); | 373 DCHECK_NE(0u, set_result); |
374 #elif defined(OS_LINUX) | 374 #elif defined(OS_LINUX) |
375 auto set_result = sched_setaffinity(0, sizeof(old_cpuset_), &old_cpuset_); | 375 auto set_result = sched_setaffinity(0, sizeof(old_cpuset_), &old_cpuset_); |
376 DCHECK_EQ(0, set_result); | 376 DCHECK_EQ(0, set_result); |
377 #endif | 377 #endif |
378 } | 378 } |
379 | 379 |
380 } // namespace test | 380 } // namespace test |
381 } // namespace IPC | 381 } // namespace IPC |
OLD | NEW |