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

Unified Diff: runtime/bin/eventhandler_macos.h

Issue 169383003: Make event-handlers edge-triggered and move socket-state to Dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | « runtime/bin/eventhandler_linux.cc ('k') | 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 cb765c64c8bf8c92aed931a91af9e50971e4b42d..96865669c050e5ad4f5333e904decf2197719e3a 100644
--- a/runtime/bin/eventhandler_macos.h
+++ b/runtime/bin/eventhandler_macos.h
@@ -10,6 +10,7 @@
#endif
#include <unistd.h>
+#include <errno.h>
#include <sys/event.h> // NOLINT
#include <sys/socket.h>
@@ -27,21 +28,13 @@ class InterruptMessage {
};
-enum PortDataFlags {
- kClosedRead = 0,
- kClosedWrite = 1,
-};
-
-
class SocketData {
public:
explicit SocketData(intptr_t fd)
: fd_(fd),
port_(0),
mask_(0),
- flags_(0),
- read_tracked_by_kqueue_(false),
- write_tracked_by_kqueue_(false) {
+ tracked_by_kqueue_(false) {
ASSERT(fd_ != -1);
}
@@ -50,29 +43,21 @@ class SocketData {
void ShutdownRead() {
shutdown(fd_, SHUT_RD);
- MarkClosedRead();
}
void ShutdownWrite() {
shutdown(fd_, SHUT_WR);
- MarkClosedWrite();
}
void Close() {
port_ = 0;
mask_ = 0;
- flags_ = 0;
close(fd_);
fd_ = -1;
}
bool IsListeningSocket() { return (mask_ & (1 << kListeningSocket)) != 0; }
bool IsPipe() { return (mask_ & (1 << kPipe)) != 0; }
- bool IsClosedRead() { return (flags_ & (1 << kClosedRead)) != 0; }
- bool IsClosedWrite() { return (flags_ & (1 << kClosedWrite)) != 0; }
-
- void MarkClosedRead() { flags_ |= (1 << kClosedRead); }
- void MarkClosedWrite() { flags_ |= (1 << kClosedWrite); }
void SetPortAndMask(Dart_Port port, intptr_t mask) {
ASSERT(fd_ != -1);
@@ -83,22 +68,16 @@ 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;
+ bool tracked_by_kqueue() { return tracked_by_kqueue_; }
+ void set_tracked_by_kqueue(bool value) {
+ 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_;
+ bool tracked_by_kqueue_;
};
@@ -109,7 +88,7 @@ class EventHandlerImplementation {
// Gets the socket data structure for a given file
// descriptor. Creates a new one if one is not found.
- SocketData* GetSocketData(intptr_t fd);
+ SocketData* GetSocketData(intptr_t fd, bool* is_new);
void SendData(intptr_t id, Dart_Port dart_port, int64_t data);
void Start(EventHandler* handler);
void Shutdown();
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698