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

Unified Diff: runtime/bin/eventhandler.h

Issue 17851004: One event handler for all isolates (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove unused line. Created 7 years, 5 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 | « no previous file | runtime/bin/eventhandler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler.h
diff --git a/runtime/bin/eventhandler.h b/runtime/bin/eventhandler.h
index 5d7832e730cce3177a1f353d1a2aebcf02061b0b..e75250f6271d8669a0184835472c92e0d465c4ef 100644
--- a/runtime/bin/eventhandler.h
+++ b/runtime/bin/eventhandler.h
@@ -27,6 +27,61 @@ enum MessageFlags {
kPipe = 17,
};
+
+class TimeoutQueue {
+ private:
+ class Timeout {
+ public:
+ Timeout(Dart_Port port, int64_t timeout, Timeout* next)
+ : port_(port), timeout_(timeout), next_(next) {}
+
+ Dart_Port port() const { return port_; }
+
+ int64_t timeout() const { return timeout_; }
+ void set_timeout(int64_t timeout) {
+ ASSERT(timeout >= 0);
+ timeout_ = timeout;
+ }
+
+ Timeout* next() const { return next_; }
+ void set_next(Timeout* next) {
+ next_ = next;
+ }
+
+ private:
+ Dart_Port port_;
+ int64_t timeout_;
+ Timeout* next_;
+ };
+
+ public:
+ TimeoutQueue() : next_timeout_(NULL), timeouts_(NULL) {}
+
+ ~TimeoutQueue() {
+ while (HasTimeout()) RemoveCurrent();
+ }
+
+ bool HasTimeout() const { return next_timeout_ != NULL; }
+
+ int64_t CurrentTimeout() const {
+ return next_timeout_->timeout();
+ }
+
+ Dart_Port CurrentPort() const {
+ return next_timeout_->port();
+ }
+
+ void RemoveCurrent() {
+ UpdateTimeout(CurrentPort(), -1);
+ }
+
+ void UpdateTimeout(Dart_Port port, int64_t timeout);
+
+ private:
+ Timeout* next_timeout_;
+ Timeout* timeouts_;
+};
+
} // namespace bin
} // namespace dart
@@ -59,12 +114,11 @@ class EventHandler {
static EventHandler* Start() {
EventHandler* handler = new EventHandler();
handler->delegate_.Start(handler);
- IsolateData* isolate_data =
- reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData());
- isolate_data->event_handler = handler;
return handler;
}
+ static void Stop();
+
private:
friend class EventHandlerImplementation;
EventHandlerImplementation delegate_;
« no previous file with comments | « no previous file | runtime/bin/eventhandler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698