Remove unused method, SetAffinity, from the ThreadWrapper class.

The method was also not consistently implemented across all platforms.

R=pbos@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/33169004

Cr-Commit-Position: refs/heads/master@{#8212}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8212 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tommi@webrtc.org
2015-01-30 09:42:37 +00:00
parent 6752b85ff7
commit 2bbc35d896
6 changed files with 0 additions and 76 deletions

View File

@ -72,14 +72,6 @@ class ThreadWrapper {
// not.
virtual bool Start(unsigned int& id) = 0;
// Sets the threads CPU affinity. CPUs are listed 0 - (number of CPUs - 1).
// The numbers in processor_numbers specify which CPUs are allowed to run the
// thread. processor_numbers should not contain any duplicates and elements
// should be lower than (number of CPUs - 1). amount_of_processors should be
// equal to the number of processors listed in processor_numbers.
virtual bool SetAffinity(const int* processor_numbers,
const unsigned int amount_of_processors);
// Stops the spawned thread and waits for it to be reclaimed with a timeout
// of two seconds. Will return false if the thread was not reclaimed.
// Multiple tries to Stop are allowed (e.g. to wait longer than 2 seconds).

View File

@ -28,9 +28,4 @@ ThreadWrapper* ThreadWrapper::CreateThread(ThreadRunFunction func,
#endif
}
bool ThreadWrapper::SetAffinity(const int* processor_numbers,
const unsigned int amount_of_processors) {
return false;
}
} // namespace webrtc

View File

@ -208,49 +208,6 @@ bool ThreadPosix::Start(unsigned int& thread_id)
return true;
}
// CPU_ZERO and CPU_SET are not available in NDK r7, so disable
// SetAffinity on Android for now.
#if (defined(WEBRTC_LINUX) && (!defined(WEBRTC_ANDROID)))
bool ThreadPosix::SetAffinity(const int* processor_numbers,
const unsigned int amount_of_processors) {
if (!processor_numbers || (amount_of_processors == 0)) {
return false;
}
cpu_set_t mask;
CPU_ZERO(&mask);
for (unsigned int processor = 0;
processor < amount_of_processors;
++processor) {
CPU_SET(processor_numbers[processor], &mask);
}
#if defined(WEBRTC_ANDROID)
// Android.
const int result = syscall(__NR_sched_setaffinity,
pid_,
sizeof(mask),
&mask);
#else
// "Normal" Linux.
const int result = sched_setaffinity(pid_,
sizeof(mask),
&mask);
#endif
if (result != 0) {
return false;
}
return true;
}
#else
// NOTE: On Mac OS X, use the Thread affinity API in
// /usr/include/mach/thread_policy.h: thread_policy_set and mach_thread_self()
// instead of Linux gettid() syscall.
bool ThreadPosix::SetAffinity(const int* , const unsigned int) {
return false;
}
#endif
void ThreadPosix::SetNotAlive() {
CriticalSectionScoped cs(crit_state_);
alive_ = false;

View File

@ -35,9 +35,6 @@ class ThreadPosix : public ThreadWrapper {
// From ThreadWrapper.
virtual void SetNotAlive() OVERRIDE;
virtual bool Start(unsigned int& id) OVERRIDE;
// Not implemented on Mac.
virtual bool SetAffinity(const int* processor_numbers,
unsigned int amount_of_processors) OVERRIDE;
virtual bool Stop() OVERRIDE;
void Run();

View File

@ -102,21 +102,6 @@ bool ThreadWindows::Start(unsigned int& thread_id) {
return true;
}
bool ThreadWindows::SetAffinity(const int* processor_numbers,
const unsigned int amount_of_processors) {
DWORD_PTR processor_bit_mask = 0;
for (unsigned int processor_index = 0;
processor_index < amount_of_processors;
++processor_index) {
// Convert from an array with processor numbers to a bitmask
// Processor numbers start at zero.
// TODO(hellner): this looks like a bug. Shouldn't the '=' be a '+='?
// Or even better |=
processor_bit_mask = 1 << processor_numbers[processor_index];
}
return SetThreadAffinityMask(thread_, processor_bit_mask) != 0;
}
void ThreadWindows::SetNotAlive() {
alive_ = false;
}

View File

@ -27,8 +27,6 @@ class ThreadWindows : public ThreadWrapper {
virtual ~ThreadWindows();
virtual bool Start(unsigned int& id);
bool SetAffinity(const int* processor_numbers,
const unsigned int amount_of_processors);
virtual bool Stop();
virtual void SetNotAlive();