| 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 public: | 24 public: |
| 25 intptr_t id; | 25 intptr_t id; |
| 26 Dart_Port dart_port; | 26 Dart_Port dart_port; |
| 27 int64_t data; | 27 int64_t data; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 | 30 |
| 31 class SocketData { | 31 class SocketData { |
| 32 public: | 32 public: |
| 33 explicit SocketData(intptr_t fd) | 33 explicit SocketData(intptr_t fd) |
| 34 : tracked_by_epoll_(false), fd_(fd), port_(0), mask_(0) { | 34 : tracked_by_epoll_(false), fd_(fd), port_(0) { |
| 35 ASSERT(fd_ != -1); | 35 ASSERT(fd_ != -1); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void ShutdownRead() { | 38 void ShutdownRead() { |
| 39 shutdown(fd_, SHUT_RD); | 39 shutdown(fd_, SHUT_RD); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void ShutdownWrite() { | 42 void ShutdownWrite() { |
| 43 shutdown(fd_, SHUT_WR); | 43 shutdown(fd_, SHUT_WR); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void Close() { | 46 void Close() { |
| 47 port_ = 0; | 47 port_ = 0; |
| 48 mask_ = 0; | |
| 49 close(fd_); | 48 close(fd_); |
| 50 fd_ = -1; | 49 fd_ = -1; |
| 51 } | 50 } |
| 52 | 51 |
| 53 bool IsListeningSocket() { return (mask_ & (1 << kListeningSocket)) != 0; } | 52 void SetPort(Dart_Port port) { |
| 54 bool IsPipe() { return (mask_ & (1 << kPipe)) != 0; } | |
| 55 | |
| 56 void SetPortAndMask(Dart_Port port, intptr_t mask) { | |
| 57 ASSERT(fd_ != -1); | 53 ASSERT(fd_ != -1); |
| 58 port_ = port; | 54 port_ = port; |
| 59 mask_ = mask; | |
| 60 } | 55 } |
| 61 | 56 |
| 62 intptr_t fd() { return fd_; } | 57 intptr_t fd() { return fd_; } |
| 63 Dart_Port port() { return port_; } | 58 Dart_Port port() { return port_; } |
| 64 intptr_t mask() { return mask_; } | |
| 65 bool tracked_by_epoll() { return tracked_by_epoll_; } | 59 bool tracked_by_epoll() { return tracked_by_epoll_; } |
| 66 void set_tracked_by_epoll(bool value) { tracked_by_epoll_ = value; } | 60 void set_tracked_by_epoll(bool value) { tracked_by_epoll_ = value; } |
| 67 | 61 |
| 68 private: | 62 private: |
| 69 bool tracked_by_epoll_; | 63 bool tracked_by_epoll_; |
| 70 intptr_t fd_; | 64 intptr_t fd_; |
| 71 Dart_Port port_; | 65 Dart_Port port_; |
| 72 intptr_t mask_; | 66 intptr_t mask_; |
| 73 }; | 67 }; |
| 74 | 68 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 100 bool shutdown_; | 94 bool shutdown_; |
| 101 int interrupt_fds_[2]; | 95 int interrupt_fds_[2]; |
| 102 int epoll_fd_; | 96 int epoll_fd_; |
| 103 int timer_fd_; | 97 int timer_fd_; |
| 104 }; | 98 }; |
| 105 | 99 |
| 106 } // namespace bin | 100 } // namespace bin |
| 107 } // namespace dart | 101 } // namespace dart |
| 108 | 102 |
| 109 #endif // BIN_EVENTHANDLER_LINUX_H_ | 103 #endif // BIN_EVENTHANDLER_LINUX_H_ |
| OLD | NEW |