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

Unified Diff: runtime/vm/port.cc

Issue 8588040: Add a mid-sized integration test for the Dart Embedding Api which (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/port.h ('k') | runtime/vm/port_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/port.cc
===================================================================
--- runtime/vm/port.cc (revision 1904)
+++ runtime/vm/port.cc (working copy)
@@ -75,6 +75,15 @@
}
+void PortMap::SetLive(Dart_Port port) {
+ MutexLocker ml(mutex_);
+ intptr_t index = FindPort(port);
+ ASSERT(index >= 0);
+ map_[index].live = true;
+ map_[index].isolate->increment_live_ports();
+}
+
+
void PortMap::MaintainInvariants() {
intptr_t empty = capacity_ - used_ - deleted_;
if (used_ > ((capacity_ / 4) * 3)) {
@@ -90,12 +99,12 @@
Dart_Port PortMap::CreatePort() {
Isolate* isolate = Isolate::Current();
-
MutexLocker ml(mutex_);
Entry entry;
entry.port = AllocatePort();
entry.isolate = isolate;
+ entry.live = false;
// Search for the first unused slot. Make use of the knowledge that here is
// currently no port with this id in the port map.
@@ -119,7 +128,7 @@
deleted_--;
}
map_[index] = entry;
- isolate->increment_active_ports();
+ isolate->increment_num_ports();
// Increment number of used slots and grow if necessary.
used_++;
@@ -145,7 +154,10 @@
// pending messages below.
map_[index].port = 0;
map_[index].isolate = deleted_entry_;
- isolate->decrement_active_ports();
+ isolate->decrement_num_ports();
+ if (map_[index].live) {
+ isolate->decrement_live_ports();
+ }
used_--;
deleted_++;
@@ -169,7 +181,7 @@
// Mark the slot as deleted.
map_[i].port = 0;
map_[i].isolate = deleted_entry_;
- isolate->decrement_active_ports();
+ isolate->decrement_num_ports();
used_--;
deleted_++;
@@ -185,12 +197,6 @@
}
-bool PortMap::IsActivePort(Dart_Port port) {
- MutexLocker ml(mutex_);
- return (FindPort(port) >= 0);
-}
-
-
bool PortMap::PostMessage(Dart_Port dest_port,
Dart_Port reply_port,
Dart_Message message) {
« no previous file with comments | « runtime/vm/port.h ('k') | runtime/vm/port_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698