| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/assert.h" | 5 #include "vm/assert.h" |
| 6 #include "vm/message_queue.h" | 6 #include "vm/message_queue.h" |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 OS::Sleep(5); | 130 OS::Sleep(5); |
| 131 for (int i = 0; i < 3; i++) { | 131 for (int i = 0; i < 3; i++) { |
| 132 int* data = reinterpret_cast<int*>(malloc(sizeof(*data))); | 132 int* data = reinterpret_cast<int*>(malloc(sizeof(*data))); |
| 133 *data = i+2000; | 133 *data = i+2000; |
| 134 PortMessage* msg = new PortMessage(i+20, i+200, data); | 134 PortMessage* msg = new PortMessage(i+20, i+200, data); |
| 135 shared_queue->Enqueue(msg); | 135 shared_queue->Enqueue(msg); |
| 136 } | 136 } |
| 137 | 137 |
| 138 sync = NULL; | 138 sync = NULL; |
| 139 delete sync; | 139 delete sync; |
| 140 |
| 141 // Give the spawned thread enough time to properly exit. |
| 142 OS::Sleep(20); |
| 140 } | 143 } |
| 141 | 144 |
| 142 | 145 |
| 143 TEST_CASE(MessageQueue_FlushAll) { | 146 TEST_CASE(MessageQueue_FlushAll) { |
| 144 MessageQueue queue; | 147 MessageQueue queue; |
| 145 MessageQueueTestPeer queue_peer(&queue); | 148 MessageQueueTestPeer queue_peer(&queue); |
| 146 Dart_Port port1 = 1; | 149 Dart_Port port1 = 1; |
| 147 Dart_Port port2 = 2; | 150 Dart_Port port2 = 2; |
| 148 | 151 |
| 149 // Add two messages. | 152 // Add two messages. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 217 |
| 215 EXPECT(!queue_peer.HasMessage()); | 218 EXPECT(!queue_peer.HasMessage()); |
| 216 queue.Flush(port1); | 219 queue.Flush(port1); |
| 217 | 220 |
| 218 // Queue is still empty. | 221 // Queue is still empty. |
| 219 EXPECT(!queue_peer.HasMessage()); | 222 EXPECT(!queue_peer.HasMessage()); |
| 220 } | 223 } |
| 221 | 224 |
| 222 | 225 |
| 223 } // namespace dart | 226 } // namespace dart |
| OLD | NEW |