summaryrefslogtreecommitdiffstats
path: root/base/thread.h
diff options
context:
space:
mode:
authoravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-07 20:12:28 +0000
committeravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-07 20:12:28 +0000
commite82b706db2d3da13746b66fd5ab7d5dd38fab17e (patch)
tree481f0dc57f23c984b5a5b0a9c169b6e928b9258f /base/thread.h
parentf3adb5c4f36fd3233d0c0baad5eaef76da462a87 (diff)
downloadchromium_src-e82b706db2d3da13746b66fd5ab7d5dd38fab17e.zip
chromium_src-e82b706db2d3da13746b66fd5ab7d5dd38fab17e.tar.gz
chromium_src-e82b706db2d3da13746b66fd5ab7d5dd38fab17e.tar.bz2
Port in threading for Posix. Will require fixes to MessageLoop and Task to compile on the Mac, though.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@532 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/thread.h')
-rw-r--r--base/thread.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/base/thread.h b/base/thread.h
index 7ed2402..1780d85 100644
--- a/base/thread.h
+++ b/base/thread.h
@@ -30,7 +30,6 @@
#ifndef BASE_THREAD_H__
#define BASE_THREAD_H__
-#include <wtypes.h>
#include <string>
#include "base/basictypes.h"
@@ -38,6 +37,14 @@
class MessageLoop;
+// Types that differ
+#if defined(OS_WIN)
+#include <wtypes.h>
+typedef unsigned int ThreadId;
+#elif defined(OS_POSIX)
+typedef pthread_t ThreadId;
+#endif
+
// A simple thread abstraction that establishes a MessageLoop on a new thread.
// The consumer uses the MessageLoop of the thread to cause code to execute on
// the thread. When this object is destroyed the thread is terminated. All
@@ -90,7 +97,7 @@ class Thread {
void NonBlockingStop();
// Returns the message loop for this thread. Use the MessageLoop's
- // Posttask methods to execute code on the thread. This only returns
+ // PostTask methods to execute code on the thread. This only returns
// non-null after a successful call to Start. After Stop has been called,
// this will return NULL.
//
@@ -108,7 +115,7 @@ class Thread {
// Sets the thread name if a debugger is currently attached. Has no effect
// otherwise. To set the name of the current thread, pass GetCurrentThreadId()
// as the tid parameter.
- static void SetThreadName(const char* name, DWORD tid);
+ static void SetThreadName(const char* name, ThreadId tid);
protected:
// Called just prior to starting the message loop
@@ -121,10 +128,12 @@ class Thread {
void InternalStop(bool run_message_loop);
private:
+#ifdef OS_WIN
static unsigned __stdcall ThreadFunc(void* param);
-
HANDLE thread_;
- unsigned thread_id_;
+#endif
+
+ ThreadId thread_id_;
MessageLoop* message_loop_;
std::string name_;
static TLSSlot tls_index_;