Add support for linking classes.
Change-Id: I0026be6e4c919f7391fd83c654f58c3bc67f44e1
diff --git a/src/thread.h b/src/thread.h
new file mode 100644
index 0000000..b1bfb33
--- /dev/null
+++ b/src/thread.h
@@ -0,0 +1,96 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+// Author: cshapiro@google.com (Carl Shapiro)
+
+#ifndef ART_SRC_THREAD_H_
+#define ART_SRC_THREAD_H_
+
+#include "src/globals.h"
+#include "src/logging.h"
+#include "src/macros.h"
+
+namespace art {
+
+class Object;
+class Thread;
+
+class Mutex {
+ public:
+ virtual ~Mutex() {}
+
+ void Lock() {}
+
+ bool TryLock() { return true; }
+
+ void Unlock() {}
+
+ const char* GetName() { return name_; }
+
+ Thread* GetOwner() { return owner_; }
+
+ public: // TODO: protected
+ explicit Mutex(const char* name) : name_(name), owner_(NULL) {}
+
+ void SetOwner(Thread* thread) { owner_ = thread; }
+
+ private:
+ const char* name_;
+
+ Thread* owner_;
+
+ DISALLOW_COPY_AND_ASSIGN(Mutex);
+};
+
+class MutexLock {
+ public:
+ explicit MutexLock(Mutex *mu) : mu_(mu) {
+ mu_->Lock();
+ }
+ ~MutexLock() { mu_->Unlock(); }
+ private:
+ Mutex* const mu_;
+ DISALLOW_COPY_AND_ASSIGN(MutexLock);
+};
+
+class Thread {
+ public:
+ static Thread* Self() {
+ static Thread self;
+ return &self; // TODO
+ }
+
+ uint32_t GetThreadId() {
+ return thread_id_;
+ }
+
+ bool IsExceptionPending() const {
+ return false; // TODO exception_ != NULL;
+ }
+
+ Object* GetException() const {
+ return exception_;
+ }
+
+ void SetException(Object* new_exception) {
+ CHECK(new_exception != NULL);
+ // TODO: CHECK(exception_ == NULL);
+ exception_ = new_exception; // TODO
+ }
+
+ void ClearException() {
+ exception_ = NULL;
+ }
+
+ private:
+ Thread() : thread_id_(1234), exception_(NULL) {}
+ ~Thread() {}
+
+ uint32_t thread_id_;
+
+ Object* exception_;
+
+ DISALLOW_COPY_AND_ASSIGN(Thread);
+};
+
+} // namespace art
+
+#endif // ART_SRC_THREAD_H_