Reformatted thread and static_instance.

BUG=
TEST=Trybots.

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3324 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
phoglund@webrtc.org
2013-01-02 08:45:03 +00:00
parent a19d04e707
commit ec9c942e45
9 changed files with 534 additions and 589 deletions

View File

@ -11,7 +11,8 @@
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_
#include "thread_wrapper.h"
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
#include <pthread.h>
namespace webrtc {
@ -19,54 +20,54 @@ namespace webrtc {
class CriticalSectionWrapper;
class EventWrapper;
int ConvertToSystemPriority(ThreadPriority priority, int minPrio, int maxPrio);
int ConvertToSystemPriority(ThreadPriority priority, int min_prio,
int max_prio);
class ThreadPosix : public ThreadWrapper
{
public:
static ThreadWrapper* Create(ThreadRunFunction func, ThreadObj obj,
ThreadPriority prio, const char* threadName);
class ThreadPosix : public ThreadWrapper {
public:
static ThreadWrapper* Create(ThreadRunFunction func, ThreadObj obj,
ThreadPriority prio, const char* thread_name);
ThreadPosix(ThreadRunFunction func, ThreadObj obj, ThreadPriority prio,
const char* threadName);
~ThreadPosix();
ThreadPosix(ThreadRunFunction func, ThreadObj obj, ThreadPriority prio,
const char* thread_name);
~ThreadPosix();
// From ThreadWrapper
virtual void SetNotAlive();
virtual bool Start(unsigned int& id);
// Not implemented on Mac
virtual bool SetAffinity(const int* processorNumbers,
unsigned int amountOfProcessors);
virtual bool Stop();
// From ThreadWrapper.
virtual void SetNotAlive();
virtual bool Start(unsigned int& id);
// Not implemented on Mac.
virtual bool SetAffinity(const int* processor_numbers,
unsigned int amount_of_processors);
virtual bool Stop();
void Run();
void Run();
private:
int Construct();
private:
int Construct();
private:
// processing function
ThreadRunFunction _runFunction;
ThreadObj _obj;
private:
ThreadRunFunction run_function_;
ThreadObj obj_;
// internal state
CriticalSectionWrapper* _crit_state; // Protects _alive and _dead
bool _alive;
bool _dead;
ThreadPriority _prio;
EventWrapper* _event;
// Internal state.
CriticalSectionWrapper* crit_state_; // Protects alive_ and dead_
bool alive_;
bool dead_;
ThreadPriority prio_;
EventWrapper* event_;
// zero-terminated thread name string
char _name[kThreadMaxNameLength];
bool _setThreadName;
// Zero-terminated thread name string.
char name_[kThreadMaxNameLength];
bool set_thread_name_;
// handle to thread
// Handle to thread.
#if (defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID))
pid_t _pid;
pid_t pid_;
#endif
pthread_attr_t _attr;
pthread_t _thread;
pthread_attr_t attr_;
pthread_t thread_;
};
} // namespace webrtc
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_