OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Native Client Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_INIT_KERNEL_SERVICE_H_ |
| 6 #define NATIVE_CLIENT_SRC_UNTRUSTED_INIT_KERNEL_SERVICE_H_ |
| 7 |
| 8 namespace nacl { |
| 9 |
| 10 class Thread; |
| 11 |
| 12 typedef void *(*ThreadStartFunction)( |
| 13 Thread *interface); |
| 14 |
| 15 typedef int (*ThreadFactoryFunction)( |
| 16 void *factory_data, |
| 17 ThreadStartFunction start_routine, |
| 18 void *thread_data, |
| 19 Thread **out_new_thread); |
| 20 |
| 21 class Thread : public RefCountBase { |
| 22 public: |
| 23 virtual int Start(); |
| 24 virtual void LaunchCallback() = 0; |
| 25 virtual void Exit(void *thread_return); |
| 26 |
| 27 protected: |
| 28 Thread(ThreadFactoryFunction factory, |
| 29 void *factory_data, |
| 30 ThreadStartFunction start_routine, |
| 31 void *thread_data); |
| 32 virtual ~Thread(); |
| 33 |
| 34 private: |
| 35 ThreadFactoryFunction factory_; |
| 36 void *factory_data_; |
| 37 |
| 38 // Whether the thread was successfully started. |
| 39 bool started_; |
| 40 |
| 41 // Whether the thread is in the middle of stopping. |
| 42 bool stopping_; |
| 43 |
| 44 // Used to pass data to ThreadMain. |
| 45 ThreadStartFunction start_routine_; |
| 46 void *startup_data; |
| 47 |
| 48 // The threads's handle. |
| 49 pthread_t thread_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 52 }; |
| 53 |
| 54 } // namespace nacl |
| 55 |
| 56 #endif |
OLD | NEW |