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 "vm/port.h" | 5 #include "vm/port.h" |
6 | 6 |
7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 if (map_[index].state == kLivePort) { | 209 if (map_[index].state == kLivePort) { |
210 handler->decrement_live_ports(); | 210 handler->decrement_live_ports(); |
211 } | 211 } |
212 | 212 |
213 used_--; | 213 used_--; |
214 deleted_++; | 214 deleted_++; |
215 MaintainInvariants(); | 215 MaintainInvariants(); |
216 } | 216 } |
217 handler->ClosePort(port); | 217 handler->ClosePort(port); |
218 if (!handler->HasLivePorts() && handler->OwnedByPortMap()) { | 218 if (!handler->HasLivePorts() && handler->OwnedByPortMap()) { |
219 delete handler; | 219 // Delete handler as soon as it isn't busy with a task. |
| 220 handler->RequestDeletion(); |
220 } | 221 } |
221 return true; | 222 return true; |
222 } | 223 } |
223 | 224 |
224 | 225 |
225 void PortMap::ClosePorts(MessageHandler* handler) { | 226 void PortMap::ClosePorts(MessageHandler* handler) { |
226 { | 227 { |
227 MutexLocker ml(mutex_); | 228 MutexLocker ml(mutex_); |
228 for (intptr_t i = 0; i < capacity_; i++) { | 229 for (intptr_t i = 0; i < capacity_; i++) { |
229 if (map_[i].handler == handler) { | 230 if (map_[i].handler == handler) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 OS::Print("Live Port = %" Pd64 "\n", map_[i].port); | 339 OS::Print("Live Port = %" Pd64 "\n", map_[i].port); |
339 msg_handler = DartLibraryCalls::LookupHandler(map_[i].port); | 340 msg_handler = DartLibraryCalls::LookupHandler(map_[i].port); |
340 OS::Print("Handler = %s\n", msg_handler.ToCString()); | 341 OS::Print("Handler = %s\n", msg_handler.ToCString()); |
341 } | 342 } |
342 } | 343 } |
343 } | 344 } |
344 } | 345 } |
345 | 346 |
346 | 347 |
347 } // namespace dart | 348 } // namespace dart |
OLD | NEW |