| 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 #include "vm/message_handler.h" | 5 #include "vm/message_handler.h" |
| 6 #include "vm/port.h" | 6 #include "vm/port.h" |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 // Start a thread which sends more messages. | 393 // Start a thread which sends more messages. |
| 394 Dart_Port* ports = new Dart_Port[10]; | 394 Dart_Port* ports = new Dart_Port[10]; |
| 395 for (int i = 0; i < 10; i++) { | 395 for (int i = 0; i < 10; i++) { |
| 396 ports[i] = PortMap::CreatePort(&handler); | 396 ports[i] = PortMap::CreatePort(&handler); |
| 397 } | 397 } |
| 398 ThreadStartInfo info; | 398 ThreadStartInfo info; |
| 399 info.handler = &handler; | 399 info.handler = &handler; |
| 400 info.ports = ports; | 400 info.ports = ports; |
| 401 info.count = 10; | 401 info.count = 10; |
| 402 OSThread::Start(SendMessages, reinterpret_cast<uword>(&info)); | 402 OSThread::Start("SendMessages", SendMessages, reinterpret_cast<uword>(&info)); |
| 403 while (sleep < kMaxSleep && handler.message_count() < 11) { | 403 while (sleep < kMaxSleep && handler.message_count() < 11) { |
| 404 OS::Sleep(10); | 404 OS::Sleep(10); |
| 405 sleep += 10; | 405 sleep += 10; |
| 406 } | 406 } |
| 407 handler_ports = handler.port_buffer(); | 407 handler_ports = handler.port_buffer(); |
| 408 EXPECT_EQ(11, handler.message_count()); | 408 EXPECT_EQ(11, handler.message_count()); |
| 409 EXPECT(handler.start_called()); | 409 EXPECT(handler.start_called()); |
| 410 EXPECT(!handler.end_called()); | 410 EXPECT(!handler.end_called()); |
| 411 EXPECT_EQ(port, handler_ports[0]); | 411 EXPECT_EQ(port, handler_ports[0]); |
| 412 for (int i = 1; i < 11; i++) { | 412 for (int i = 1; i < 11; i++) { |
| 413 EXPECT_EQ(ports[i - 1], handler_ports[i]); | 413 EXPECT_EQ(ports[i - 1], handler_ports[i]); |
| 414 } | 414 } |
| 415 handler_peer.decrement_live_ports(); | 415 handler_peer.decrement_live_ports(); |
| 416 EXPECT(!handler.HasLivePorts()); | 416 EXPECT(!handler.HasLivePorts()); |
| 417 PortMap::ClosePorts(&handler); | 417 PortMap::ClosePorts(&handler); |
| 418 } | 418 } |
| 419 | 419 |
| 420 } // namespace dart | 420 } // namespace dart |
| OLD | NEW |