| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -231,82 +231,82 @@ void ClearFatalExceptionHandlers(Environment* env); | |||
| 231 | 231 | enum NodeInstanceType { MAIN, WORKER, REMOTE_DEBUG_SERVER }; | |
| 232 | 232 | ||
| 233 | 233 | class NodeInstanceData { | |
| 234 | - public: | ||
| 235 | - NodeInstanceData(NodeInstanceType node_instance_type, | ||
| 236 | - uv_loop_t* event_loop, | ||
| 237 | - int argc, | ||
| 238 | - const char** argv, | ||
| 239 | - int exec_argc, | ||
| 240 | - const char** exec_argv, | ||
| 241 | - bool use_debug_agent_flag) | ||
| 242 | - : node_instance_type_(node_instance_type), | ||
| 243 | - exit_code_(1), | ||
| 244 | - event_loop_(event_loop), | ||
| 245 | - argc_(argc), | ||
| 246 | - argv_(argv), | ||
| 247 | - exec_argc_(exec_argc), | ||
| 248 | - exec_argv_(exec_argv), | ||
| 249 | - use_debug_agent_flag_(use_debug_agent_flag) { | ||
| 250 | - CHECK_NE(event_loop_, nullptr); | ||
| 251 | - } | ||
| 252 | - | ||
| 253 | - uv_loop_t* event_loop() const { | ||
| 254 | - return event_loop_; | ||
| 255 | - } | ||
| 256 | - | ||
| 257 | - int exit_code() { | ||
| 258 | - CHECK(is_main()); | ||
| 259 | - return exit_code_; | ||
| 260 | - } | ||
| 261 | - | ||
| 262 | - void set_exit_code(int exit_code) { | ||
| 263 | - CHECK(is_main()); | ||
| 264 | - exit_code_ = exit_code; | ||
| 265 | - } | ||
| 266 | - | ||
| 267 | - bool is_main() { | ||
| 268 | - return node_instance_type_ == MAIN; | ||
| 269 | - } | ||
| 270 | - | ||
| 271 | - bool is_worker() { | ||
| 272 | - return node_instance_type_ == WORKER; | ||
| 273 | - } | ||
| 274 | - | ||
| 275 | - bool is_remote_debug_server() { | ||
| 276 | - return node_instance_type_ == REMOTE_DEBUG_SERVER; | ||
| 277 | - } | ||
| 278 | - | ||
| 279 | - int argc() { | ||
| 280 | - return argc_; | ||
| 281 | - } | ||
| 282 | - | ||
| 283 | - const char** argv() { | ||
| 284 | - return argv_; | ||
| 285 | - } | ||
| 286 | - | ||
| 287 | - int exec_argc() { | ||
| 288 | - return exec_argc_; | ||
| 289 | - } | ||
| 290 | - | ||
| 291 | - const char** exec_argv() { | ||
| 292 | - return exec_argv_; | ||
| 293 | - } | ||
| 294 | - | ||
| 295 | - bool use_debug_agent() { | ||
| 296 | - return is_main() && use_debug_agent_flag_; | ||
| 297 | - } | ||
| 298 | - | ||
| 299 | - private: | ||
| 300 | - const NodeInstanceType node_instance_type_; | ||
| 301 | - int exit_code_; | ||
| 302 | - uv_loop_t* const event_loop_; | ||
| 303 | - const int argc_; | ||
| 304 | - const char** argv_; | ||
| 305 | - const int exec_argc_; | ||
| 306 | - const char** exec_argv_; | ||
| 307 | - const bool use_debug_agent_flag_; | ||
| 308 | - | ||
| 309 | - DISALLOW_COPY_AND_ASSIGN(NodeInstanceData); | ||
| 234 | + public: | ||
| 235 | + NodeInstanceData(NodeInstanceType node_instance_type, | ||
| 236 | + uv_loop_t* event_loop, | ||
| 237 | + int argc, | ||
| 238 | + const char** argv, | ||
| 239 | + int exec_argc, | ||
| 240 | + const char** exec_argv, | ||
| 241 | + bool use_debug_agent_flag) | ||
| 242 | + : node_instance_type_(node_instance_type), | ||
| 243 | + exit_code_(1), | ||
| 244 | + event_loop_(event_loop), | ||
| 245 | + argc_(argc), | ||
| 246 | + argv_(argv), | ||
| 247 | + exec_argc_(exec_argc), | ||
| 248 | + exec_argv_(exec_argv), | ||
| 249 | + use_debug_agent_flag_(use_debug_agent_flag) { | ||
| 250 | + CHECK_NE(event_loop_, nullptr); | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + uv_loop_t* event_loop() const { | ||
| 254 | + return event_loop_; | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + int exit_code() { | ||
| 258 | + CHECK(is_main()); | ||
| 259 | + return exit_code_; | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + void set_exit_code(int exit_code) { | ||
| 263 | + CHECK(is_main()); | ||
| 264 | + exit_code_ = exit_code; | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + bool is_main() { | ||
| 268 | + return node_instance_type_ == MAIN; | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + bool is_worker() { | ||
| 272 | + return node_instance_type_ == WORKER; | ||
| 273 | + } | ||
| 274 | + | ||
| 275 | + bool is_remote_debug_server() { | ||
| 276 | + return node_instance_type_ == REMOTE_DEBUG_SERVER; | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + int argc() { | ||
| 280 | + return argc_; | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + const char** argv() { | ||
| 284 | + return argv_; | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | + int exec_argc() { | ||
| 288 | + return exec_argc_; | ||
| 289 | + } | ||
| 290 | + | ||
| 291 | + const char** exec_argv() { | ||
| 292 | + return exec_argv_; | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + bool use_debug_agent() { | ||
| 296 | + return is_main() && use_debug_agent_flag_; | ||
| 297 | + } | ||
| 298 | + | ||
| 299 | + private: | ||
| 300 | + const NodeInstanceType node_instance_type_; | ||
| 301 | + int exit_code_; | ||
| 302 | + uv_loop_t* const event_loop_; | ||
| 303 | + const int argc_; | ||
| 304 | + const char** argv_; | ||
| 305 | + const int exec_argc_; | ||
| 306 | + const char** exec_argv_; | ||
| 307 | + const bool use_debug_agent_flag_; | ||
| 308 | + | ||
| 309 | + DISALLOW_COPY_AND_ASSIGN(NodeInstanceData); | ||
| 310 | 310 | }; | |
| 311 | 311 | ||
| 312 | 312 | namespace Buffer { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,56 +39,57 @@ class Watchdog { | |||
| 39 | 39 | }; | |
| 40 | 40 | ||
| 41 | 41 | class SigintWatchdog { | |
| 42 | - public: | ||
| 43 | - explicit SigintWatchdog(v8::Isolate* isolate); | ||
| 44 | - ~SigintWatchdog(); | ||
| 42 | + public: | ||
| 43 | + explicit SigintWatchdog(v8::Isolate* isolate); | ||
| 44 | + ~SigintWatchdog(); | ||
| 45 | 45 | ||
| 46 | - void Dispose(); | ||
| 46 | + void Dispose(); | ||
| 47 | 47 | ||
| 48 | - v8::Isolate* isolate() { return isolate_; } | ||
| 49 | - bool HasReceivedSignal() { return received_signal_; } | ||
| 50 | - void HandleSigint(); | ||
| 51 | - private: | ||
| 52 | - void Destroy(); | ||
| 48 | + v8::Isolate* isolate() { return isolate_; } | ||
| 49 | + bool HasReceivedSignal() { return received_signal_; } | ||
| 50 | + void HandleSigint(); | ||
| 51 | + | ||
| 52 | + private: | ||
| 53 | + void Destroy(); | ||
| 53 | 54 | ||
| 54 | - v8::Isolate* isolate_; | ||
| 55 | - bool received_signal_; | ||
| 56 | - bool destroyed_; | ||
| 55 | + v8::Isolate* isolate_; | ||
| 56 | + bool received_signal_; | ||
| 57 | + bool destroyed_; | ||
| 57 | 58 | }; | |
| 58 | 59 | ||
| 59 | 60 | class SigintWatchdogHelper { | |
| 60 | - public: | ||
| 61 | - static SigintWatchdogHelper* GetInstance() { return &instance; } | ||
| 62 | - void Register(SigintWatchdog* watchdog); | ||
| 63 | - void Unregister(SigintWatchdog* watchdog); | ||
| 61 | + public: | ||
| 62 | + static SigintWatchdogHelper* GetInstance() { return &instance; } | ||
| 63 | + void Register(SigintWatchdog* watchdog); | ||
| 64 | + void Unregister(SigintWatchdog* watchdog); | ||
| 64 | 65 | ||
| 65 | - int Start(); | ||
| 66 | - bool Stop(); | ||
| 66 | + int Start(); | ||
| 67 | + bool Stop(); | ||
| 67 | 68 | ||
| 68 | - private: | ||
| 69 | - SigintWatchdogHelper(); | ||
| 70 | - ~SigintWatchdogHelper(); | ||
| 69 | + private: | ||
| 70 | + SigintWatchdogHelper(); | ||
| 71 | + ~SigintWatchdogHelper(); | ||
| 71 | 72 | ||
| 72 | - static bool InformWatchdogsAboutSignal(); | ||
| 73 | - static SigintWatchdogHelper instance; | ||
| 73 | + static bool InformWatchdogsAboutSignal(); | ||
| 74 | + static SigintWatchdogHelper instance; | ||
| 74 | 75 | ||
| 75 | - int start_stop_count_; | ||
| 76 | + int start_stop_count_; | ||
| 76 | 77 | ||
| 77 | - uv_mutex_t mutex_; | ||
| 78 | - uv_mutex_t list_mutex_; | ||
| 79 | - std::vector<SigintWatchdog*> watchdogs_; | ||
| 80 | - bool has_pending_signal_; | ||
| 78 | + uv_mutex_t mutex_; | ||
| 79 | + uv_mutex_t list_mutex_; | ||
| 80 | + std::vector<SigintWatchdog*> watchdogs_; | ||
| 81 | + bool has_pending_signal_; | ||
| 81 | 82 | ||
| 82 | 83 | #ifdef __POSIX__ | |
| 83 | - pthread_t thread_; | ||
| 84 | - uv_sem_t sem_; | ||
| 85 | - bool has_running_thread_; | ||
| 86 | - bool stopping_; | ||
| 84 | + pthread_t thread_; | ||
| 85 | + uv_sem_t sem_; | ||
| 86 | + bool has_running_thread_; | ||
| 87 | + bool stopping_; | ||
| 87 | 88 | ||
| 88 | - static void* RunSigintWatchdog(void* arg); | ||
| 89 | - static void HandleSignal(int signum); | ||
| 89 | + static void* RunSigintWatchdog(void* arg); | ||
| 90 | + static void HandleSignal(int signum); | ||
| 90 | 91 | #else | |
| 91 | - static BOOL WINAPI WinCtrlCHandlerRoutine(DWORD dwCtrlType); | ||
| 92 | + static BOOL WINAPI WinCtrlCHandlerRoutine(DWORD dwCtrlType); | ||
| 92 | 93 | #endif | |
| 93 | 94 | }; | |
| 94 | 95 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,78 +27,78 @@ using v8::Value; | |||
| 27 | 27 | ||
| 28 | 28 | template <typename ResourceType, typename TypeName> | |
| 29 | 29 | class ExternString: public ResourceType { | |
| 30 | - public: | ||
| 31 | - ~ExternString() override { | ||
| 32 | - free(const_cast<TypeName*>(data_)); | ||
| 33 | - isolate()->AdjustAmountOfExternalAllocatedMemory(-byte_length()); | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - const TypeName* data() const override { | ||
| 37 | - return data_; | ||
| 38 | - } | ||
| 30 | + public: | ||
| 31 | + ~ExternString() override { | ||
| 32 | + free(const_cast<TypeName*>(data_)); | ||
| 33 | + isolate()->AdjustAmountOfExternalAllocatedMemory(-byte_length()); | ||
| 34 | + } | ||
| 39 | 35 | ||
| 40 | - size_t length() const override { | ||
| 41 | - return length_; | ||
| 42 | - } | ||
| 36 | + const TypeName* data() const override { | ||
| 37 | + return data_; | ||
| 38 | + } | ||
| 43 | 39 | ||
| 44 | - int64_t byte_length() const { | ||
| 45 | - return length() * sizeof(*data()); | ||
| 46 | - } | ||
| 40 | + size_t length() const override { | ||
| 41 | + return length_; | ||
| 42 | + } | ||
| 47 | 43 | ||
| 48 | - static Local<String> NewFromCopy(Isolate* isolate, | ||
| 49 | - const TypeName* data, | ||
| 50 | - size_t length) { | ||
| 51 | - EscapableHandleScope scope(isolate); | ||
| 44 | + int64_t byte_length() const { | ||
| 45 | + return length() * sizeof(*data()); | ||
| 46 | + } | ||
| 52 | 47 | ||
| 53 | - if (length == 0) | ||
| 54 | - return scope.Escape(String::Empty(isolate)); | ||
| 48 | + static Local<String> NewFromCopy(Isolate* isolate, | ||
| 49 | + const TypeName* data, | ||
| 50 | + size_t length) { | ||
| 51 | + EscapableHandleScope scope(isolate); | ||
| 55 | 52 | ||
| 56 | - TypeName* new_data = | ||
| 57 | - static_cast<TypeName*>(malloc(length * sizeof(*new_data))); | ||
| 58 | - if (new_data == nullptr) { | ||
| 59 | - return Local<String>(); | ||
| 60 | - } | ||
| 61 | - memcpy(new_data, data, length * sizeof(*new_data)); | ||
| 53 | + if (length == 0) | ||
| 54 | + return scope.Escape(String::Empty(isolate)); | ||
| 62 | 55 | ||
| 63 | - return scope.Escape(ExternString<ResourceType, TypeName>::New(isolate, | ||
| 64 | - new_data, | ||
| 65 | - length)); | ||
| 56 | + TypeName* new_data = | ||
| 57 | + static_cast<TypeName*>(malloc(length * sizeof(*new_data))); | ||
| 58 | + if (new_data == nullptr) { | ||
| 59 | + return Local<String>(); | ||
| 66 | 60 | } | |
| 61 | + memcpy(new_data, data, length * sizeof(*new_data)); | ||
| 67 | 62 | ||
| 68 | - // uses "data" for external resource, and will be free'd on gc | ||
| 69 | - static Local<String> New(Isolate* isolate, | ||
| 70 | - const TypeName* data, | ||
| 71 | - size_t length) { | ||
| 72 | - EscapableHandleScope scope(isolate); | ||
| 63 | + return scope.Escape(ExternString<ResourceType, TypeName>::New(isolate, | ||
| 64 | + new_data, | ||
| 65 | + length)); | ||
| 66 | + } | ||
| 73 | 67 | ||
| 74 | - if (length == 0) | ||
| 75 | - return scope.Escape(String::Empty(isolate)); | ||
| 68 | + // uses "data" for external resource, and will be free'd on gc | ||
| 69 | + static Local<String> New(Isolate* isolate, | ||
| 70 | + const TypeName* data, | ||
| 71 | + size_t length) { | ||
| 72 | + EscapableHandleScope scope(isolate); | ||
| 76 | 73 | ||
| 77 | - ExternString* h_str = new ExternString<ResourceType, TypeName>(isolate, | ||
| 78 | - data, | ||
| 79 | - length); | ||
| 80 | - MaybeLocal<String> str = NewExternal(isolate, h_str); | ||
| 81 | - isolate->AdjustAmountOfExternalAllocatedMemory(h_str->byte_length()); | ||
| 74 | + if (length == 0) | ||
| 75 | + return scope.Escape(String::Empty(isolate)); | ||
| 82 | 76 | ||
| 83 | - if (str.IsEmpty()) { | ||
| 84 | - delete h_str; | ||
| 85 | - return Local<String>(); | ||
| 86 | - } | ||
| 77 | + ExternString* h_str = new ExternString<ResourceType, TypeName>(isolate, | ||
| 78 | + data, | ||
| 79 | + length); | ||
| 80 | + MaybeLocal<String> str = NewExternal(isolate, h_str); | ||
| 81 | + isolate->AdjustAmountOfExternalAllocatedMemory(h_str->byte_length()); | ||
| 87 | 82 | ||
| 88 | - return scope.Escape(str.ToLocalChecked()); | ||
| 83 | + if (str.IsEmpty()) { | ||
| 84 | + delete h_str; | ||
| 85 | + return Local<String>(); | ||
| 89 | 86 | } | |
| 90 | 87 | ||
| 91 | - inline Isolate* isolate() const { return isolate_; } | ||
| 88 | + return scope.Escape(str.ToLocalChecked()); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + inline Isolate* isolate() const { return isolate_; } | ||
| 92 | 92 | ||
| 93 | - private: | ||
| 94 | - ExternString(Isolate* isolate, const TypeName* data, size_t length) | ||
| 95 | - : isolate_(isolate), data_(data), length_(length) { } | ||
| 96 | - static MaybeLocal<String> NewExternal(Isolate* isolate, | ||
| 97 | - ExternString* h_str); | ||
| 93 | + private: | ||
| 94 | + ExternString(Isolate* isolate, const TypeName* data, size_t length) | ||
| 95 | + : isolate_(isolate), data_(data), length_(length) { } | ||
| 96 | + static MaybeLocal<String> NewExternal(Isolate* isolate, | ||
| 97 | + ExternString* h_str); | ||
| 98 | 98 | ||
| 99 | - Isolate* isolate_; | ||
| 100 | - const TypeName* data_; | ||
| 101 | - size_t length_; | ||
| 99 | + Isolate* isolate_; | ||
| 100 | + const TypeName* data_; | ||
| 101 | + size_t length_; | ||
| 102 | 102 | }; | |
| 103 | 103 | ||
| 104 | 104 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments