| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 EXPECT_EQ(i+2000, *(reinterpret_cast<int*>(msg->data()))); | 93 EXPECT_EQ(i+2000, *(reinterpret_cast<int*>(msg->data()))); |
| 94 delete msg; | 94 delete msg; |
| 95 } | 95 } |
| 96 shared_queue = NULL; | 96 shared_queue = NULL; |
| 97 delete queue; | 97 delete queue; |
| 98 Dart::ShutdownIsolate(); | 98 Dart::ShutdownIsolate(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 TEST_CASE(MessageQueue_WaitNotify) { | 102 TEST_CASE(MessageQueue_WaitNotify) { |
| 103 sync = new Monitor(); |
| 104 |
| 103 Thread* thread = new Thread(MessageReceiver_start, 0); | 105 Thread* thread = new Thread(MessageReceiver_start, 0); |
| 104 EXPECT(thread != NULL); | 106 EXPECT(thread != NULL); |
| 105 | 107 |
| 106 // Wait for the shared queue to be created. | 108 // Wait for the shared queue to be created. |
| 107 sync = new Monitor(); | |
| 108 { | 109 { |
| 109 MonitorLocker ml(sync); | 110 MonitorLocker ml(sync); |
| 110 ml.Wait(0); | 111 ml.Wait(0); |
| 111 } | 112 } |
| 112 ASSERT(shared_queue != NULL); | 113 ASSERT(shared_queue != NULL); |
| 113 | 114 |
| 114 // Pile up three messages before the other thread runs. | 115 // Pile up three messages before the other thread runs. |
| 115 for (int i = 0; i < 3; i++) { | 116 for (int i = 0; i < 3; i++) { |
| 116 int* data = reinterpret_cast<int*>(malloc(sizeof(*data))); | 117 int* data = reinterpret_cast<int*>(malloc(sizeof(*data))); |
| 117 *data = i+1000; | 118 *data = i+1000; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 218 |
| 218 EXPECT(!queue_peer.HasMessage()); | 219 EXPECT(!queue_peer.HasMessage()); |
| 219 queue.Flush(port1); | 220 queue.Flush(port1); |
| 220 | 221 |
| 221 // Queue is still empty. | 222 // Queue is still empty. |
| 222 EXPECT(!queue_peer.HasMessage()); | 223 EXPECT(!queue_peer.HasMessage()); |
| 223 } | 224 } |
| 224 | 225 |
| 225 | 226 |
| 226 } // namespace dart | 227 } // namespace dart |
| OLD | NEW |