| 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/os.h" | 7 #include "vm/os.h" |
| 8 #include "vm/port.h" | 8 #include "vm/port.h" |
| 9 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
| 10 | 10 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 | 159 |
| 160 static PortMessage* NextMessage() { | 160 static PortMessage* NextMessage() { |
| 161 Isolate* isolate = Isolate::Current(); | 161 Isolate* isolate = Isolate::Current(); |
| 162 PortMessage* result = isolate->message_queue()->Dequeue(0); | 162 PortMessage* result = isolate->message_queue()->Dequeue(0); |
| 163 return result; | 163 return result; |
| 164 } | 164 } |
| 165 | 165 |
| 166 | 166 |
| 167 void ThreadedPort_start(uword parameter) { | 167 void ThreadedPort_start(uword parameter) { |
| 168 Dart::CreateIsolate(NULL, NULL); | 168 // We only need an isolate here because the MutexLocker in |
| 169 // PortMap::CreatePort expects it, we don't need to initialize |
| 170 // the isolate as it does not run any dart code. |
| 171 Dart::CreateIsolate(); |
| 169 | 172 |
| 170 intptr_t remote = parameter; | 173 intptr_t remote = parameter; |
| 171 intptr_t local = PortMap::CreatePort(); | 174 intptr_t local = PortMap::CreatePort(); |
| 172 | 175 |
| 173 PortMap::PostMessage(remote, 0, AllocIntData(local)); | 176 PortMap::PostMessage(remote, 0, AllocIntData(local)); |
| 174 | 177 |
| 175 intptr_t count = 0; | 178 intptr_t count = 0; |
| 176 while (true) { | 179 while (true) { |
| 177 PortMessage* msg = NextMessage(); | 180 PortMessage* msg = NextMessage(); |
| 178 EXPECT_EQ(local, msg->dest_port()); | 181 EXPECT_EQ(local, msg->dest_port()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // Give the spawned thread enough time to properly exit. | 225 // Give the spawned thread enough time to properly exit. |
| 223 Monitor* waiter = new Monitor(); | 226 Monitor* waiter = new Monitor(); |
| 224 { | 227 { |
| 225 MonitorLocker ml(waiter); | 228 MonitorLocker ml(waiter); |
| 226 ml.Wait(20); | 229 ml.Wait(20); |
| 227 } | 230 } |
| 228 delete waiter; | 231 delete waiter; |
| 229 } | 232 } |
| 230 | 233 |
| 231 } // namespace dart | 234 } // namespace dart |
| OLD | NEW |