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

Unified Diff: runtime/vm/message.h

Issue 9169063: Add support for native ports in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/message.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/message.h
===================================================================
--- runtime/vm/message.h (revision 3603)
+++ runtime/vm/message.h (working copy)
@@ -2,12 +2,14 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-#ifndef VM_MESSAGE_QUEUE_H_
-#define VM_MESSAGE_QUEUE_H_
+#ifndef VM_MESSAGE_H_
+#define VM_MESSAGE_H_
-#include "include/dart_api.h"
#include "vm/thread.h"
+// Duplicated from dart_api.h to avoid including the whole header.
+typedef int64_t Dart_Port;
+
namespace dart {
class Message {
@@ -22,7 +24,7 @@
} Priority;
// A port number which is never used.
- static const int kIllegalPort = 0;
+ static const Dart_Port kIllegalPort = 0;
// A new message to be sent between two isolates. The data handed to this
// message will be disposed by calling free() once the message object is
@@ -57,7 +59,6 @@
DISALLOW_COPY_AND_ASSIGN(Message);
};
-
// There is a message queue per isolate.
class MessageQueue {
public:
@@ -92,6 +93,60 @@
DISALLOW_COPY_AND_ASSIGN(MessageQueue);
};
+// A MessageHandler is an entity capable of accepting messages.
+class MessageHandler {
+ protected:
+ MessageHandler();
+
+ // Allows subclasses to provide custom message notification.
+ virtual void MessageNotify(Message::Priority priority);
+
+ public:
+ virtual ~MessageHandler();
+
+ // Allow subclasses to provide a handler name.
+ virtual const char* name() const;
+
+#if defined(DEBUG)
+ // Check that it is safe to access this message handler.
+ //
+ // For example, if this MessageHandler is an isolate, then it is
+ // only safe to access it when the MessageHandler is the current
+ // isolate.
+ virtual void CheckAccess();
+#endif
+
+ void PostMessage(Message* message);
+ void ClosePort(Dart_Port port);
+ void CloseAllPorts();
+
+ // A message handler tracks how many live ports it has.
+ bool HasLivePorts() const { return live_ports_ > 0; }
+ void increment_live_ports() {
+#if defined(DEBUG)
+ CheckAccess();
+#endif
+ live_ports_++;
+ }
+ void decrement_live_ports() {
+#if defined(DEBUG)
+ CheckAccess();
+#endif
+ live_ports_--;
+ }
+
+ // Returns true if the handler is owned by the PortMap.
+ //
+ // This is used to delete handlers when their last live port is closed.
+ virtual bool OwnedByPortMap() const { return false; }
+
+ MessageQueue* queue() const { return queue_; }
+
+ private:
+ intptr_t live_ports_;
+ MessageQueue* queue_;
+};
+
} // namespace dart
-#endif // VM_MESSAGE_QUEUE_H_
+#endif // VM_MESSAGE_H_
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698