| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BIN_EVENTHANDLER_ANDROID_H_ | 5 #ifndef BIN_EVENTHANDLER_ANDROID_H_ |
| 6 #define BIN_EVENTHANDLER_ANDROID_H_ | 6 #define BIN_EVENTHANDLER_ANDROID_H_ |
| 7 | 7 |
| 8 #if !defined(BIN_EVENTHANDLER_H_) | 8 #if !defined(BIN_EVENTHANDLER_H_) |
| 9 #error Do not include eventhandler_android.h directly; | 9 #error Do not include eventhandler_android.h directly; |
| 10 #error use eventhandler.h instead. | 10 #error use eventhandler.h instead. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 public: | 26 public: |
| 27 intptr_t id; | 27 intptr_t id; |
| 28 Dart_Port dart_port; | 28 Dart_Port dart_port; |
| 29 int64_t data; | 29 int64_t data; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 | 32 |
| 33 class SocketData { | 33 class SocketData { |
| 34 public: | 34 public: |
| 35 explicit SocketData(intptr_t fd) | 35 explicit SocketData(intptr_t fd) |
| 36 : fd_(fd), port_(0), mask_(0), tokens_(8) { | 36 : fd_(fd), port_(0), mask_(0), tokens_(16) { |
| 37 ASSERT(fd_ != -1); | 37 ASSERT(fd_ != -1); |
| 38 } | 38 } |
| 39 | 39 |
| 40 intptr_t GetPollEvents(); | 40 intptr_t GetPollEvents(); |
| 41 | 41 |
| 42 void Close() { | 42 void Close() { |
| 43 port_ = 0; | 43 port_ = 0; |
| 44 mask_ = 0; | 44 mask_ = 0; |
| 45 VOID_TEMP_FAILURE_RETRY(close(fd_)); | 45 VOID_TEMP_FAILURE_RETRY(close(fd_)); |
| 46 fd_ = -1; | 46 fd_ = -1; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void SetPortAndMask(Dart_Port port, intptr_t mask) { | 49 void SetPortAndMask(Dart_Port port, intptr_t mask) { |
| 50 ASSERT(fd_ != -1); | 50 ASSERT(fd_ != -1); |
| 51 port_ = port; | 51 port_ = port; |
| 52 mask_ = mask; | 52 mask_ = mask; |
| 53 } | 53 } |
| 54 | 54 |
| 55 intptr_t fd() { return fd_; } | 55 intptr_t fd() { return fd_; } |
| 56 Dart_Port port() { return port_; } | 56 Dart_Port port() { return port_; } |
| 57 | 57 |
| 58 bool IsListeningSocket() { return (mask_ & (1 << kListeningSocket)) != 0; } |
| 59 |
| 58 // Returns true if the last token was taken. | 60 // Returns true if the last token was taken. |
| 59 bool TakeToken() { | 61 bool TakeToken() { |
| 60 ASSERT(tokens_ > 0); | 62 ASSERT(tokens_ > 0); |
| 61 tokens_--; | 63 tokens_--; |
| 62 return tokens_ == 0; | 64 return tokens_ == 0; |
| 63 } | 65 } |
| 64 | 66 |
| 65 // Returns true if the tokens was 0 before adding. | 67 // Returns true if the tokens was 0 before adding. |
| 66 bool ReturnToken() { | 68 bool ReturnToken() { |
| 67 ASSERT(tokens_ >= 0); | 69 ASSERT(tokens_ >= 0); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 TimeoutQueue timeout_queue_; | 107 TimeoutQueue timeout_queue_; |
| 106 bool shutdown_; | 108 bool shutdown_; |
| 107 int interrupt_fds_[2]; | 109 int interrupt_fds_[2]; |
| 108 int epoll_fd_; | 110 int epoll_fd_; |
| 109 }; | 111 }; |
| 110 | 112 |
| 111 } // namespace bin | 113 } // namespace bin |
| 112 } // namespace dart | 114 } // namespace dart |
| 113 | 115 |
| 114 #endif // BIN_EVENTHANDLER_ANDROID_H_ | 116 #endif // BIN_EVENTHANDLER_ANDROID_H_ |
| OLD | NEW |