| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 delete msg1; | 51 delete msg1; |
| 52 delete msg2; | 52 delete msg2; |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 // A thread which receives an expected sequence of messages. | 56 // A thread which receives an expected sequence of messages. |
| 57 static Monitor* sync = NULL; | 57 static Monitor* sync = NULL; |
| 58 static MessageQueue* shared_queue = NULL; | 58 static MessageQueue* shared_queue = NULL; |
| 59 void MessageReceiver_start(uword unused) { | 59 void MessageReceiver_start(uword unused) { |
| 60 // We only need an isolate here because the MonitorLocker in the | 60 // We only need an isolate here because the MonitorLocker in the |
| 61 // MessageQueue expects it. | 61 // MessageQueue expects it, we don't need to initialize the isolate |
| 62 Dart::CreateIsolate(NULL, NULL); | 62 // as it does not run any dart code. |
| 63 Dart::CreateIsolate(); |
| 63 | 64 |
| 64 // Create a message queue and share it. | 65 // Create a message queue and share it. |
| 65 MessageQueue* queue = new MessageQueue(); | 66 MessageQueue* queue = new MessageQueue(); |
| 66 MessageQueueTestPeer peer(queue); | 67 MessageQueueTestPeer peer(queue); |
| 67 shared_queue = queue; | 68 shared_queue = queue; |
| 68 | 69 |
| 69 // Tell the other thread that the shared queue is ready. | 70 // Tell the other thread that the shared queue is ready. |
| 70 { | 71 { |
| 71 MonitorLocker ml(sync); | 72 MonitorLocker ml(sync); |
| 72 ml.Notify(); | 73 ml.Notify(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 220 |
| 220 EXPECT(!queue_peer.HasMessage()); | 221 EXPECT(!queue_peer.HasMessage()); |
| 221 queue.Flush(port1); | 222 queue.Flush(port1); |
| 222 | 223 |
| 223 // Queue is still empty. | 224 // Queue is still empty. |
| 224 EXPECT(!queue_peer.HasMessage()); | 225 EXPECT(!queue_peer.HasMessage()); |
| 225 } | 226 } |
| 226 | 227 |
| 227 | 228 |
| 228 } // namespace dart | 229 } // namespace dart |
| OLD | NEW |