Index: src/untrusted/init/thread.h |
diff --git a/src/untrusted/init/thread.h b/src/untrusted/init/thread.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8dc9a0033edb321ea5bc08b015842a32e8ad6cbe |
--- /dev/null |
+++ b/src/untrusted/init/thread.h |
@@ -0,0 +1,56 @@ |
+// Copyright (c) 2013 The Native Client Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef NATIVE_CLIENT_SRC_UNTRUSTED_INIT_KERNEL_SERVICE_H_ |
+#define NATIVE_CLIENT_SRC_UNTRUSTED_INIT_KERNEL_SERVICE_H_ |
+ |
+namespace nacl { |
+ |
+class Thread; |
+ |
+typedef void *(*ThreadStartFunction)( |
+ Thread *interface); |
+ |
+typedef int (*ThreadFactoryFunction)( |
+ void *factory_data, |
+ ThreadStartFunction start_routine, |
+ void *thread_data, |
+ Thread **out_new_thread); |
+ |
+class Thread : public RefCountBase { |
+ public: |
+ virtual int Start(); |
+ virtual void LaunchCallback() = 0; |
+ virtual void Exit(void *thread_return); |
+ |
+ protected: |
+ Thread(ThreadFactoryFunction factory, |
+ void *factory_data, |
+ ThreadStartFunction start_routine, |
+ void *thread_data); |
+ virtual ~Thread(); |
+ |
+ private: |
+ ThreadFactoryFunction factory_; |
+ void *factory_data_; |
+ |
+ // Whether the thread was successfully started. |
+ bool started_; |
+ |
+ // Whether the thread is in the middle of stopping. |
+ bool stopping_; |
+ |
+ // Used to pass data to ThreadMain. |
+ ThreadStartFunction start_routine_; |
+ void *startup_data; |
+ |
+ // The threads's handle. |
+ pthread_t thread_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Thread); |
+}; |
+ |
+} // namespace nacl |
+ |
+#endif |