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

Unified Diff: runtime/bin/eventhandler_macos.h

Issue 198743002: Make the event-handler handle backpreasure. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Doc fix Created 6 years, 9 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 acbfc9177103eeec45db304d6a9243a816a86dfb..70a103c87ee0297b79df5115e08d80213150cf3e 100644
--- a/runtime/bin/eventhandler_macos.h
+++ b/runtime/bin/eventhandler_macos.h
@@ -10,7 +10,6 @@
#endif
#include <unistd.h>
-#include <errno.h>
#include <sys/event.h> // NOLINT
#include <sys/socket.h>
@@ -34,21 +33,14 @@ class SocketData {
: fd_(fd),
port_(0),
mask_(0),
- tracked_by_kqueue_(false) {
+ tracked_by_kqueue_(false),
+ tokens_(8) {
ASSERT(fd_ != -1);
}
bool HasReadEvent();
bool HasWriteEvent();
- void ShutdownRead() {
- shutdown(fd_, SHUT_RD);
- }
-
- void ShutdownWrite() {
- shutdown(fd_, SHUT_WR);
- }
-
void Close() {
port_ = 0;
mask_ = 0;
@@ -57,7 +49,6 @@ class SocketData {
}
bool IsListeningSocket() { return (mask_ & (1 << kListeningSocket)) != 0; }
- bool IsPipe() { return (mask_ & (1 << kPipe)) != 0; }
void SetPortAndMask(Dart_Port port, intptr_t mask) {
ASSERT(fd_ != -1);
@@ -73,11 +64,24 @@ class SocketData {
tracked_by_kqueue_ = value;
}
+ // Returns true if the last token was taken.
+ bool TakeToken() {
+ tokens_--;
+ return tokens_ == 0;
+ }
+
+ // Returns true if the tokens was 0 before adding.
+ bool ReturnToken() {
+ tokens_++;
+ return tokens_ == 1;
+ }
+
private:
intptr_t fd_;
Dart_Port port_;
intptr_t mask_;
bool tracked_by_kqueue_;
+ int tokens_;
};
@@ -88,8 +92,8 @@ 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, bool* is_new);
- void Notify(intptr_t id, Dart_Port dart_port, int64_t data);
+ SocketData* GetSocketData(intptr_t fd);
+ 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