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(); |