Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: runtime/vm/message_queue_test.cc

Issue 8344017: Fix race. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698