Remove ThreadObj #define and kThreadMaxNameLength from thread_wrapper.

BUG=
R=hbos@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#8792}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8792 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tommi@webrtc.org 2015-03-19 14:35:58 +00:00
parent 0c26299739
commit 27c0be9dfe
11 changed files with 11 additions and 18 deletions

View File

@ -21,11 +21,6 @@
namespace webrtc { namespace webrtc {
// Object that will be passed by the spawned thread when it enters the callback
// function.
// TODO(tommi): Remove this define.
#define ThreadObj void*
// Callback function that the spawned thread will enter once spawned. // Callback function that the spawned thread will enter once spawned.
// A return value of false is interpreted as that the function has no // A return value of false is interpreted as that the function has no
// more work to do and that the thread can be released. // more work to do and that the thread can be released.
@ -44,8 +39,6 @@ enum ThreadPriority {
// called from the same thread, including instantiation. // called from the same thread, including instantiation.
class ThreadWrapper { class ThreadWrapper {
public: public:
enum {kThreadMaxNameLength = 64};
virtual ~ThreadWrapper() {} virtual ~ThreadWrapper() {}
// Factory method. Constructor disabled. // Factory method. Constructor disabled.

View File

@ -164,7 +164,7 @@ bool EventPosix::StartTimer(bool periodic, unsigned long time) {
return started; return started;
} }
bool EventPosix::Run(ThreadObj obj) { bool EventPosix::Run(void* obj) {
return static_cast<EventPosix*>(obj)->Process(); return static_cast<EventPosix*>(obj)->Process();
} }

View File

@ -40,7 +40,7 @@ class EventPosix : public EventWrapper {
private: private:
EventPosix(); EventPosix();
static bool Run(ThreadObj obj); static bool Run(void* obj);
bool Process(); bool Process();
EventTypeWrapper Wait(timespec* end_at); EventTypeWrapper Wait(timespec* end_at);

View File

@ -19,7 +19,7 @@
namespace webrtc { namespace webrtc {
ThreadWrapper* ThreadWrapper::CreateThread(ThreadRunFunction func, ThreadWrapper* ThreadWrapper::CreateThread(ThreadRunFunction func,
ThreadObj obj, ThreadPriority prio, void* obj, ThreadPriority prio,
const char* thread_name) { const char* thread_name) {
#if defined(_WIN32) #if defined(_WIN32)
return new ThreadWindows(func, obj, prio, thread_name); return new ThreadWindows(func, obj, prio, thread_name);

View File

@ -68,7 +68,7 @@ void* ThreadPosix::StartThread(void* param) {
return 0; return 0;
} }
ThreadPosix::ThreadPosix(ThreadRunFunction func, ThreadObj obj, ThreadPosix::ThreadPosix(ThreadRunFunction func, void* obj,
ThreadPriority prio, const char* thread_name) ThreadPriority prio, const char* thread_name)
: run_function_(func), : run_function_(func),
obj_(obj), obj_(obj),
@ -76,7 +76,7 @@ ThreadPosix::ThreadPosix(ThreadRunFunction func, ThreadObj obj,
stop_event_(false, false), stop_event_(false, false),
name_(thread_name ? thread_name : "webrtc"), name_(thread_name ? thread_name : "webrtc"),
thread_(0) { thread_(0) {
DCHECK(name_.length() < kThreadMaxNameLength); DCHECK(name_.length() < 64);
} }
uint32_t ThreadWrapper::GetThreadId() { uint32_t ThreadWrapper::GetThreadId() {

View File

@ -25,7 +25,7 @@ int ConvertToSystemPriority(ThreadPriority priority, int min_prio,
class ThreadPosix : public ThreadWrapper { class ThreadPosix : public ThreadWrapper {
public: public:
ThreadPosix(ThreadRunFunction func, ThreadObj obj, ThreadPriority prio, ThreadPosix(ThreadRunFunction func, void* obj, ThreadPriority prio,
const char* thread_name); const char* thread_name);
~ThreadPosix() override; ~ThreadPosix() override;

View File

@ -54,7 +54,7 @@ void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName) {
} }
ThreadWindows::ThreadWindows(ThreadRunFunction func, ThreadObj obj, ThreadWindows::ThreadWindows(ThreadRunFunction func, void* obj,
ThreadPriority prio, const char* thread_name) ThreadPriority prio, const char* thread_name)
: run_function_(func), : run_function_(func),
obj_(obj), obj_(obj),

View File

@ -574,7 +574,7 @@ int32_t UdpSocket2WorkerWindows::Init()
return 0; return 0;
} }
bool UdpSocket2WorkerWindows::Run(ThreadObj obj) bool UdpSocket2WorkerWindows::Run(void* obj)
{ {
UdpSocket2WorkerWindows* pWorker = UdpSocket2WorkerWindows* pWorker =
static_cast<UdpSocket2WorkerWindows*>(obj); static_cast<UdpSocket2WorkerWindows*>(obj);

View File

@ -101,7 +101,7 @@ public:
virtual bool Stop(); virtual bool Stop();
virtual int32_t Init(); virtual int32_t Init();
protected: protected:
static bool Run(ThreadObj obj); static bool Run(void* obj);
bool Process(); bool Process();
private: private:
HANDLE _ioCompletionHandle; HANDLE _ioCompletionHandle;

View File

@ -300,7 +300,7 @@ bool UdpSocketManagerPosixImpl::Process()
return true; return true;
} }
bool UdpSocketManagerPosixImpl::Run(ThreadObj obj) bool UdpSocketManagerPosixImpl::Run(void* obj)
{ {
UdpSocketManagerPosixImpl* mgr = UdpSocketManagerPosixImpl* mgr =
static_cast<UdpSocketManagerPosixImpl*>(obj); static_cast<UdpSocketManagerPosixImpl*>(obj);

View File

@ -68,7 +68,7 @@ public:
virtual bool RemoveSocket(UdpSocketWrapper* s); virtual bool RemoveSocket(UdpSocketWrapper* s);
protected: protected:
static bool Run(ThreadObj obj); static bool Run(void* obj);
bool Process(); bool Process();
void UpdateSocketMap(); void UpdateSocketMap();