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

Unified Diff: runtime/bin/eventhandler_macos.h

Issue 9365010: Move the event handler on macos from poll to kqueue. Simpler and faster. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 8 years, 10 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_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_macos.h
diff --git a/runtime/bin/eventhandler_macos.h b/runtime/bin/eventhandler_macos.h
index 9ee388b99a7d104a45a0b7feea48c07c53bf61be..0c1c86d00697905efcf09e0d8b5cfce04fd2cc37 100644
--- a/runtime/bin/eventhandler_macos.h
+++ b/runtime/bin/eventhandler_macos.h
@@ -30,16 +30,18 @@ enum PortDataFlags {
class SocketData {
public:
- explicit SocketData(intptr_t fd) : fd_(fd), port_(0), mask_(0), flags_(0) {
+ explicit SocketData(intptr_t fd)
+ : fd_(fd),
+ port_(0),
+ mask_(0),
+ flags_(0),
+ read_tracked_by_kqueue_(false),
+ write_tracked_by_kqueue_(false) {
ASSERT(fd_ != -1);
}
- intptr_t GetPollEvents();
-
- void Unregister() {
- port_ = 0;
- mask_ = 0;
- }
+ bool HasReadEvent();
+ bool HasWriteEvent();
void ShutdownRead() {
shutdown(fd_, SHUT_RD);
@@ -52,7 +54,8 @@ class SocketData {
}
void Close() {
- Unregister();
+ port_ = 0;
+ mask_ = 0;
flags_ = 0;
close(fd_);
fd_ = -1;
@@ -66,8 +69,6 @@ class SocketData {
void MarkClosedRead() { flags_ |= (1 << kClosedRead); }
void MarkClosedWrite() { flags_ |= (1 << kClosedWrite); }
- bool HasPollEvents() { return mask_ != 0; }
-
void SetPortAndMask(Dart_Port port, intptr_t mask) {
ASSERT(fd_ != -1);
port_ = port;
@@ -77,12 +78,22 @@ class SocketData {
intptr_t fd() { return fd_; }
Dart_Port port() { return port_; }
intptr_t mask() { return mask_; }
+ bool read_tracked_by_kqueue() { return read_tracked_by_kqueue_; }
+ void set_read_tracked_by_kqueue(bool value) {
+ read_tracked_by_kqueue_ = value;
+ }
+ bool write_tracked_by_kqueue() { return write_tracked_by_kqueue_; }
+ void set_write_tracked_by_kqueue(bool value) {
+ write_tracked_by_kqueue_ = value;
+ }
private:
intptr_t fd_;
Dart_Port port_;
intptr_t mask_;
intptr_t flags_;
+ bool read_tracked_by_kqueue_;
+ bool write_tracked_by_kqueue_;
};
@@ -92,7 +103,7 @@ class EventHandlerImplementation {
~EventHandlerImplementation();
// Gets the socket data structure for a given file
- // descriptor. Creates a new one of one is not found.
+ // descriptor. Creates a new one if one is not found.
SocketData* GetSocketData(intptr_t fd);
void SendData(intptr_t id, Dart_Port dart_port, intptr_t data);
void StartEventHandler();
@@ -100,14 +111,13 @@ class EventHandlerImplementation {
private:
intptr_t GetTimeout();
bool GetInterruptMessage(InterruptMessage* msg);
- struct pollfd* GetPollFds(intptr_t* size);
- void HandleEvents(struct pollfd* pollfds, int pollfds_size, int result_size);
+ void HandleEvents(struct kevent* events, int size);
void HandleTimeout();
- static void Poll(uword args);
+ static void EventHandlerEntry(uword args);
void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data);
void HandleInterruptFd();
void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask);
- intptr_t GetPollEvents(struct pollfd* pollfd);
+ intptr_t GetEvents(struct kevent* event, SocketData* sd);
static void* GetHashmapKeyFromFd(intptr_t fd);
static uint32_t GetHashmapHashFromFd(intptr_t fd);
@@ -115,6 +125,7 @@ class EventHandlerImplementation {
int64_t timeout_; // Time for next timeout.
Dart_Port timeout_port_;
int interrupt_fds_[2];
+ int kqueue_fd_;
};
« no previous file with comments | « no previous file | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698