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

Unified Diff: runtime/bin/eventhandler_android.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.h ('k') | runtime/bin/eventhandler_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_android.h
diff --git a/runtime/bin/eventhandler_android.h b/runtime/bin/eventhandler_android.h
index 5a80eef414209e27435277427740ad9f92975a48..2647164fbf31d90782a4cf978157dd85eb5548c4 100644
--- a/runtime/bin/eventhandler_android.h
+++ b/runtime/bin/eventhandler_android.h
@@ -31,17 +31,11 @@ class InterruptMessage {
class SocketData {
public:
explicit SocketData(intptr_t fd)
- : tracked_by_epoll_(false), fd_(fd), port_(0), mask_(0) {
+ : fd_(fd), port_(0), mask_(0), tokens_(8) {
ASSERT(fd_ != -1);
}
- void ShutdownRead() {
- shutdown(fd_, SHUT_RD);
- }
-
- void ShutdownWrite() {
- shutdown(fd_, SHUT_WR);
- }
+ intptr_t GetPollEvents();
void Close() {
port_ = 0;
@@ -50,9 +44,6 @@ class SocketData {
fd_ = -1;
}
- 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);
port_ = port;
@@ -61,15 +52,26 @@ class SocketData {
intptr_t fd() { return fd_; }
Dart_Port port() { return port_; }
- intptr_t mask() { return mask_; }
- bool tracked_by_epoll() { return tracked_by_epoll_; }
- void set_tracked_by_epoll(bool value) { tracked_by_epoll_ = value; }
+
+ // Returns true if the last token was taken.
+ bool TakeToken() {
+ ASSERT(tokens_ > 0);
+ tokens_--;
+ return tokens_ == 0;
+ }
+
+ // Returns true if the tokens was 0 before adding.
+ bool ReturnToken() {
+ ASSERT(tokens_ >= 0);
+ tokens_++;
+ return tokens_ == 1;
+ }
private:
- bool tracked_by_epoll_;
intptr_t fd_;
Dart_Port port_;
intptr_t mask_;
+ int tokens_;
};
@@ -80,8 +82,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, intptr_t data);
+ SocketData* GetSocketData(intptr_t fd);
+ void SendData(intptr_t id, Dart_Port dart_port, intptr_t data);
void Start(EventHandler* handler);
void Shutdown();
« no previous file with comments | « runtime/bin/eventhandler.h ('k') | runtime/bin/eventhandler_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698