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_LINUX_H_ | 5 #ifndef BIN_EVENTHANDLER_LINUX_H_ |
6 #define BIN_EVENTHANDLER_LINUX_H_ | 6 #define BIN_EVENTHANDLER_LINUX_H_ |
7 | 7 |
8 #if !defined(BIN_EVENTHANDLER_H_) | 8 #if !defined(BIN_EVENTHANDLER_H_) |
9 #error Do not include eventhandler_linux.h directly; use eventhandler.h instead. | 9 #error Do not include eventhandler_linux.h directly; use eventhandler.h instead. |
10 #endif | 10 #endif |
(...skipping 13 matching lines...) Expand all Loading... |
24 class InterruptMessage { | 24 class InterruptMessage { |
25 public: | 25 public: |
26 intptr_t id; | 26 intptr_t id; |
27 Dart_Port dart_port; | 27 Dart_Port dart_port; |
28 int64_t data; | 28 int64_t data; |
29 }; | 29 }; |
30 | 30 |
31 | 31 |
32 class SocketData { | 32 class SocketData { |
33 public: | 33 public: |
34 explicit SocketData(intptr_t fd) : fd_(fd), port_(0), mask_(0), tokens_(8) { | 34 explicit SocketData(intptr_t fd) : fd_(fd), port_(0), mask_(0), tokens_(16) { |
35 ASSERT(fd_ != -1); | 35 ASSERT(fd_ != -1); |
36 } | 36 } |
37 | 37 |
38 intptr_t GetPollEvents(); | 38 intptr_t GetPollEvents(); |
39 | 39 |
40 void Close() { | 40 void Close() { |
41 port_ = 0; | 41 port_ = 0; |
42 mask_ = 0; | 42 mask_ = 0; |
43 VOID_TEMP_FAILURE_RETRY(close(fd_)); | 43 VOID_TEMP_FAILURE_RETRY(close(fd_)); |
44 fd_ = -1; | 44 fd_ = -1; |
45 } | 45 } |
46 | 46 |
47 void SetPortAndMask(Dart_Port port, intptr_t mask) { | 47 void SetPortAndMask(Dart_Port port, intptr_t mask) { |
48 ASSERT(fd_ != -1); | 48 ASSERT(fd_ != -1); |
49 port_ = port; | 49 port_ = port; |
50 mask_ = mask; | 50 mask_ = mask; |
51 } | 51 } |
52 | 52 |
53 intptr_t fd() { return fd_; } | 53 intptr_t fd() { return fd_; } |
54 Dart_Port port() { return port_; } | 54 Dart_Port port() { return port_; } |
55 | 55 |
| 56 bool IsListeningSocket() { return (mask_ & (1 << kListeningSocket)) != 0; } |
| 57 |
56 // Returns true if the last token was taken. | 58 // Returns true if the last token was taken. |
57 bool TakeToken() { | 59 bool TakeToken() { |
58 ASSERT(tokens_ > 0); | 60 ASSERT(tokens_ > 0); |
59 tokens_--; | 61 tokens_--; |
60 return tokens_ == 0; | 62 return tokens_ == 0; |
61 } | 63 } |
62 | 64 |
63 // Returns true if the tokens was 0 before adding. | 65 // Returns true if the tokens was 0 before adding. |
64 bool ReturnToken() { | 66 bool ReturnToken() { |
65 ASSERT(tokens_ >= 0); | 67 ASSERT(tokens_ >= 0); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 bool shutdown_; | 104 bool shutdown_; |
103 int interrupt_fds_[2]; | 105 int interrupt_fds_[2]; |
104 int epoll_fd_; | 106 int epoll_fd_; |
105 int timer_fd_; | 107 int timer_fd_; |
106 }; | 108 }; |
107 | 109 |
108 } // namespace bin | 110 } // namespace bin |
109 } // namespace dart | 111 } // namespace dart |
110 | 112 |
111 #endif // BIN_EVENTHANDLER_LINUX_H_ | 113 #endif // BIN_EVENTHANDLER_LINUX_H_ |
OLD | NEW |