OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_BIN_PROCESS_H_ | 5 #ifndef RUNTIME_BIN_PROCESS_H_ |
6 #define RUNTIME_BIN_PROCESS_H_ | 6 #define RUNTIME_BIN_PROCESS_H_ |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/io_buffer.h" | 9 #include "bin/io_buffer.h" |
10 #include "bin/lockers.h" | 10 #include "bin/lockers.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 static int GlobalExitCode() { | 119 static int GlobalExitCode() { |
120 MutexLocker ml(global_exit_code_mutex_); | 120 MutexLocker ml(global_exit_code_mutex_); |
121 return global_exit_code_; | 121 return global_exit_code_; |
122 } | 122 } |
123 | 123 |
124 static void SetGlobalExitCode(int exit_code) { | 124 static void SetGlobalExitCode(int exit_code) { |
125 MutexLocker ml(global_exit_code_mutex_); | 125 MutexLocker ml(global_exit_code_mutex_); |
126 global_exit_code_ = exit_code; | 126 global_exit_code_ = exit_code; |
127 } | 127 } |
128 | 128 |
| 129 typedef void (*ExitHook)(int64_t exit_code); |
| 130 static void SetExitHook(ExitHook hook) { |
| 131 exit_hook_ = hook; |
| 132 } |
| 133 static void RunExitHook(int64_t exit_code) { |
| 134 if (exit_hook_ != NULL) { |
| 135 exit_hook_(exit_code); |
| 136 } |
| 137 } |
| 138 |
129 static intptr_t CurrentProcessId(); | 139 static intptr_t CurrentProcessId(); |
130 | 140 |
131 static intptr_t SetSignalHandler(intptr_t signal); | 141 static intptr_t SetSignalHandler(intptr_t signal); |
132 static void ClearSignalHandler(intptr_t signal); | 142 static void ClearSignalHandler(intptr_t signal); |
133 | 143 |
134 static Dart_Handle GetProcessIdNativeField(Dart_Handle process, | 144 static Dart_Handle GetProcessIdNativeField(Dart_Handle process, |
135 intptr_t* pid); | 145 intptr_t* pid); |
136 static Dart_Handle SetProcessIdNativeField(Dart_Handle process, | 146 static Dart_Handle SetProcessIdNativeField(Dart_Handle process, |
137 intptr_t pid); | 147 intptr_t pid); |
138 | 148 |
139 private: | 149 private: |
140 static int global_exit_code_; | 150 static int global_exit_code_; |
141 static Mutex* global_exit_code_mutex_; | 151 static Mutex* global_exit_code_mutex_; |
| 152 static ExitHook exit_hook_; |
142 | 153 |
143 DISALLOW_ALLOCATION(); | 154 DISALLOW_ALLOCATION(); |
144 DISALLOW_IMPLICIT_CONSTRUCTORS(Process); | 155 DISALLOW_IMPLICIT_CONSTRUCTORS(Process); |
145 }; | 156 }; |
146 | 157 |
147 | 158 |
148 class SignalInfo { | 159 class SignalInfo { |
149 public: | 160 public: |
150 SignalInfo(intptr_t fd, intptr_t signal, SignalInfo* next) | 161 SignalInfo(intptr_t fd, intptr_t signal, SignalInfo* next) |
151 : fd_(fd), | 162 : fd_(fd), |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 intptr_t free_size_; | 299 intptr_t free_size_; |
289 | 300 |
290 private: | 301 private: |
291 DISALLOW_COPY_AND_ASSIGN(BufferListBase); | 302 DISALLOW_COPY_AND_ASSIGN(BufferListBase); |
292 }; | 303 }; |
293 | 304 |
294 } // namespace bin | 305 } // namespace bin |
295 } // namespace dart | 306 } // namespace dart |
296 | 307 |
297 #endif // RUNTIME_BIN_PROCESS_H_ | 308 #endif // RUNTIME_BIN_PROCESS_H_ |
OLD | NEW |