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
diff --git a/webrtc/system_wrappers/interface/static_instance.h b/webrtc/system_wrappers/interface/static_instance.h
index b670f96..dad9c52 100644
--- a/webrtc/system_wrappers/interface/static_instance.h
+++ b/webrtc/system_wrappers/interface/static_instance.h
@@ -8,14 +8,14 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATICINSTANCETEMPLATE_H_
-#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATICINSTANCETEMPLATE_H_
+#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATIC_INSTANCE_H_
+#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATIC_INSTANCE_H_
#include <assert.h>
-#include "critical_section_wrapper.h"
+#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#ifdef _WIN32
-#include "fix_interlocked_exchange_pointer_win.h"
+#include "webrtc/system_wrappers/interface/fix_interlocked_exchange_pointer_win.h"
#endif
namespace webrtc {
@@ -46,7 +46,7 @@
// reclaimed by the OS and memory leak tools will not recognize memory
// reachable from statics leaked so no noise is added by doing this.
static CriticalSectionWrapper* crit_sect(
- CriticalSectionWrapper::CreateCriticalSection());
+ CriticalSectionWrapper::CreateCriticalSection());
CriticalSectionScoped lock(crit_sect);
if (count_operation ==
@@ -116,8 +116,8 @@
}
}
} else {
- int newValue = InterlockedDecrement(&instance_count);
- if (newValue == 0) {
+ int new_value = InterlockedDecrement(&instance_count);
+ if (new_value == 0) {
state = kDestroy;
}
}
@@ -128,7 +128,7 @@
// local copy.
T* new_instance = T::CreateInstance();
if (1 == InterlockedIncrement(&instance_count)) {
- InterlockedExchangePointer(reinterpret_cast<void* volatile*>(&instance),
+ InterlockedExchangePointer(reinterpret_cast<void * volatile*>(&instance),
new_instance);
} else {
InterlockedDecrement(&instance_count);
@@ -137,8 +137,8 @@
}
}
} else if (state == kDestroy) {
- T* old_value = static_cast<T*> (InterlockedExchangePointer(
- reinterpret_cast<void* volatile*>(&instance), NULL));
+ T* old_value = static_cast<T*>(InterlockedExchangePointer(
+ reinterpret_cast<void * volatile*>(&instance), NULL));
if (old_value) {
delete static_cast<T*>(old_value);
}
@@ -150,4 +150,4 @@
} // namspace webrtc
-#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATICINSTANCETEMPLATE_H_
+#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_STATIC_INSTANCE_H_
diff --git a/webrtc/system_wrappers/interface/thread_wrapper.h b/webrtc/system_wrappers/interface/thread_wrapper.h
index edfc4bf..11b7894 100644
--- a/webrtc/system_wrappers/interface/thread_wrapper.h
+++ b/webrtc/system_wrappers/interface/thread_wrapper.h
@@ -16,10 +16,11 @@
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_
-#include "common_types.h"
-#include "typedefs.h"
+#include "webrtc/common_types.h"
+#include "webrtc/typedefs.h"
namespace webrtc {
+
// Object that will be passed by the spawned thread when it enters the callback
// function.
#define ThreadObj void*
@@ -27,68 +28,67 @@
// Callback function that the spawned thread will enter once spawned.
// A return value of false is interpreted as that the function has no
// more work to do and that the thread can be released.
-typedef bool(*ThreadRunFunction)(ThreadObj);
+typedef bool(*ThreadRunFunction)(ThreadObj);
-enum ThreadPriority
-{
- kLowPriority = 1,
- kNormalPriority = 2,
- kHighPriority = 3,
- kHighestPriority = 4,
- kRealtimePriority = 5
+enum ThreadPriority {
+ kLowPriority = 1,
+ kNormalPriority = 2,
+ kHighPriority = 3,
+ kHighestPriority = 4,
+ kRealtimePriority = 5
};
-class ThreadWrapper
-{
-public:
- enum {kThreadMaxNameLength = 64};
+class ThreadWrapper {
+ public:
+ enum {kThreadMaxNameLength = 64};
- virtual ~ThreadWrapper() {};
+ virtual ~ThreadWrapper() {};
- // Factory method. Constructor disabled.
- //
- // func Pointer to a, by user, specified callback function.
- // obj Object associated with the thread. Passed in the callback
- // function.
- // prio Thread priority. May require root/admin rights.
- // threadName NULL terminated thread name, will be visable in the Windows
- // debugger.
- static ThreadWrapper* CreateThread(ThreadRunFunction func = 0,
- ThreadObj obj= 0,
- ThreadPriority prio = kNormalPriority,
- const char* threadName = 0);
+ // Factory method. Constructor disabled.
+ //
+ // func Pointer to a, by user, specified callback function.
+ // obj Object associated with the thread. Passed in the callback
+ // function.
+ // prio Thread priority. May require root/admin rights.
+ // thread_name NULL terminated thread name, will be visable in the Windows
+ // debugger.
+ static ThreadWrapper* CreateThread(ThreadRunFunction func = 0,
+ ThreadObj obj = 0,
+ ThreadPriority prio = kNormalPriority,
+ const char* thread_name = 0);
- // Get the current thread's kernel thread ID.
- static uint32_t GetThreadId();
+ // Get the current thread's kernel thread ID.
+ static uint32_t GetThreadId();
- // Non blocking termination of the spawned thread. Note that it is not safe
- // to delete this class until the spawned thread has been reclaimed.
- virtual void SetNotAlive() = 0;
+ // Non blocking termination of the spawned thread. Note that it is not safe
+ // to delete this class until the spawned thread has been reclaimed.
+ virtual void SetNotAlive() = 0;
- // Tries to spawns a thread and returns true if that was successful.
- // Additionally, it tries to set thread priority according to the priority
- // from when CreateThread was called. However, failure to set priority will
- // not result in a false return value.
- // TODO(henrike): add a function for polling whether priority was set or
- // not.
- virtual bool Start(unsigned int& id) = 0;
+ // Tries to spawns a thread and returns true if that was successful.
+ // Additionally, it tries to set thread priority according to the priority
+ // from when CreateThread was called. However, failure to set priority will
+ // not result in a false return value.
+ // TODO(henrike): add a function for polling whether priority was set or
+ // not.
+ virtual bool Start(unsigned int& id) = 0;
- // Sets the threads CPU affinity. CPUs are listed 0 - (number of CPUs - 1).
- // The numbers in processorNumbers specify which CPUs are allowed to run the
- // thread. processorNumbers should not contain any duplicates and elements
- // should be lower than (number of CPUs - 1). amountOfProcessors should be
- // equal to the number of processors listed in processorNumbers
- virtual bool SetAffinity(const int* /*processorNumbers*/,
- const unsigned int /*amountOfProcessors*/) {
- return false;
- }
+ // 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) {
+ return false;
+ }
- // 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).
- // It's ok to call Stop() even if the spawned thread has been reclaimed.
- virtual bool Stop() = 0;
+ // 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).
+ // It's ok to call Stop() even if the spawned thread has been reclaimed.
+ virtual bool Stop() = 0;
};
+
} // namespace webrtc
-#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_
+#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_THREAD_WRAPPER_H_