From: yangguo@chromium.org Date: Tue, 9 Sep 2014 14:31:49 +0000 (+0000) Subject: Do not force interrupt in test-debug/ProcessDebugMessagesThreaded. X-Git-Tag: upstream/4.7.83~7032 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d6f9811dac25379625d3049657088e6f2de909c;p=platform%2Fupstream%2Fv8.git Do not force interrupt in test-debug/ProcessDebugMessagesThreaded. R=ulan@chromium.org Review URL: https://codereview.chromium.org/557773002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23810 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index 048de0b..0cdd23e 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -6531,9 +6531,25 @@ class SendCommandThread : public v8::base::Thread { semaphore_(0), isolate_(isolate) {} - static void ProcessDebugMessages(v8::Isolate* isolate, void* data) { - v8::Debug::ProcessDebugMessages(); - reinterpret_cast(data)->Signal(); + class ClientDataImpl : public v8::Debug::ClientData { + public: + explicit ClientDataImpl(v8::base::Semaphore* semaphore) + : semaphore_(semaphore) {} + v8::base::Semaphore* semaphore() { return semaphore_; } + + private: + v8::base::Semaphore* semaphore_; + }; + + static void CountingAndSignallingMessageHandler( + const v8::Debug::Message& message) { + if (message.IsResponse()) { + counting_message_handler_counter++; + ClientDataImpl* data = + reinterpret_cast(message.GetClientData()); + v8::base::Semaphore* semaphore = data->semaphore(); + semaphore->Signal(); + } } virtual void Run() { @@ -6550,18 +6566,16 @@ class SendCommandThread : public v8::base::Thread { for (int i = 0; i < 100; i++) { CHECK_EQ(i, counting_message_handler_counter); // Queue debug message. - v8::Debug::SendCommand(isolate_, buffer, length); - // Synchronize with the main thread to force message processing. - isolate_->RequestInterrupt(ProcessDebugMessages, &semaphore_); + v8::Debug::SendCommand(isolate_, buffer, length, + new ClientDataImpl(&semaphore_)); + // Wait for the message handler to pick up the response. semaphore_.Wait(); } v8::V8::TerminateExecution(isolate_); } - void StartSending() { - semaphore_.Signal(); - } + void StartSending() { semaphore_.Signal(); } private: v8::base::Semaphore semaphore_; @@ -6584,7 +6598,8 @@ TEST(ProcessDebugMessagesThreaded) { counting_message_handler_counter = 0; - v8::Debug::SetMessageHandler(CountingMessageHandler); + v8::Debug::SetMessageHandler( + SendCommandThread::CountingAndSignallingMessageHandler); send_command_thread_ = new SendCommandThread(isolate); send_command_thread_->Start();