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

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

Issue 2217693002: Delete NativeMessageHandler once a native port closes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: edits Created 4 years, 4 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
« no previous file with comments | « runtime/vm/native_message_handler.cc ('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) 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
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
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
OLDNEW
« no previous file with comments | « runtime/vm/native_message_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698