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 "platform/assert.h" | 5 #include "platform/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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 shared_queue = NULL; | 103 shared_queue = NULL; |
104 delete queue; | 104 delete queue; |
105 Dart::ShutdownIsolate(); | 105 Dart::ShutdownIsolate(); |
106 } | 106 } |
107 | 107 |
108 | 108 |
109 TEST_CASE(MessageQueue_WaitNotify) { | 109 TEST_CASE(MessageQueue_WaitNotify) { |
110 sync = new Monitor(); | 110 sync = new Monitor(); |
111 | 111 |
112 Thread* thread = new Thread(MessageReceiver_start, 0); | 112 int result = Thread::Start(MessageReceiver_start, 0); |
113 EXPECT(thread != NULL); | 113 EXPECT_EQ(0, result); |
114 | 114 |
115 // Wait for the shared queue to be created. | 115 // Wait for the shared queue to be created. |
116 while (shared_queue == NULL) { | 116 while (shared_queue == NULL) { |
117 MonitorLocker ml(sync); | 117 MonitorLocker ml(sync); |
118 ml.Wait(5); | 118 ml.Wait(5); |
119 } | 119 } |
120 ASSERT(shared_queue != NULL); | 120 ASSERT(shared_queue != NULL); |
121 | 121 |
122 // Pile up three messages before the other thread runs. | 122 // Pile up three messages before the other thread runs. |
123 for (int i = 0; i < 3; i++) { | 123 for (int i = 0; i < 3; i++) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 227 |
228 EXPECT(!queue_peer.HasMessage()); | 228 EXPECT(!queue_peer.HasMessage()); |
229 queue.Flush(port1); | 229 queue.Flush(port1); |
230 | 230 |
231 // Queue is still empty. | 231 // Queue is still empty. |
232 EXPECT(!queue_peer.HasMessage()); | 232 EXPECT(!queue_peer.HasMessage()); |
233 } | 233 } |
234 | 234 |
235 | 235 |
236 } // namespace dart | 236 } // namespace dart |
OLD | NEW |