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 RUNTIME_BIN_EVENTHANDLER_LINUX_H_ | 5 #ifndef RUNTIME_BIN_EVENTHANDLER_LINUX_H_ |
6 #define RUNTIME_BIN_EVENTHANDLER_LINUX_H_ | 6 #define RUNTIME_BIN_EVENTHANDLER_LINUX_H_ |
7 | 7 |
8 #if !defined(RUNTIME_BIN_EVENTHANDLER_H_) | 8 #if !defined(RUNTIME_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 |
11 | 11 |
12 #include <errno.h> | 12 #include <errno.h> |
13 #include <sys/epoll.h> | 13 #include <sys/epoll.h> |
14 #include <sys/socket.h> | 14 #include <sys/socket.h> |
15 #include <unistd.h> | 15 #include <unistd.h> |
16 | 16 |
17 #include "platform/hashmap.h" | 17 #include "platform/hashmap.h" |
18 #include "platform/signal_blocker.h" | 18 #include "platform/signal_blocker.h" |
19 | 19 |
20 | |
21 namespace dart { | 20 namespace dart { |
22 namespace bin { | 21 namespace bin { |
23 | 22 |
24 class DescriptorInfo : public DescriptorInfoBase { | 23 class DescriptorInfo : public DescriptorInfoBase { |
25 public: | 24 public: |
26 explicit DescriptorInfo(intptr_t fd) : DescriptorInfoBase(fd) {} | 25 explicit DescriptorInfo(intptr_t fd) : DescriptorInfoBase(fd) {} |
27 | 26 |
28 virtual ~DescriptorInfo() {} | 27 virtual ~DescriptorInfo() {} |
29 | 28 |
30 intptr_t GetPollEvents(); | 29 intptr_t GetPollEvents(); |
31 | 30 |
32 virtual void Close() { | 31 virtual void Close() { |
33 VOID_TEMP_FAILURE_RETRY(close(fd_)); | 32 VOID_TEMP_FAILURE_RETRY(close(fd_)); |
34 fd_ = -1; | 33 fd_ = -1; |
35 } | 34 } |
36 | 35 |
37 private: | 36 private: |
38 DISALLOW_COPY_AND_ASSIGN(DescriptorInfo); | 37 DISALLOW_COPY_AND_ASSIGN(DescriptorInfo); |
39 }; | 38 }; |
40 | 39 |
41 | |
42 class DescriptorInfoSingle : public DescriptorInfoSingleMixin<DescriptorInfo> { | 40 class DescriptorInfoSingle : public DescriptorInfoSingleMixin<DescriptorInfo> { |
43 public: | 41 public: |
44 explicit DescriptorInfoSingle(intptr_t fd) | 42 explicit DescriptorInfoSingle(intptr_t fd) |
45 : DescriptorInfoSingleMixin(fd, false) {} | 43 : DescriptorInfoSingleMixin(fd, false) {} |
46 virtual ~DescriptorInfoSingle() {} | 44 virtual ~DescriptorInfoSingle() {} |
47 | 45 |
48 private: | 46 private: |
49 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoSingle); | 47 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoSingle); |
50 }; | 48 }; |
51 | 49 |
52 | |
53 class DescriptorInfoMultiple | 50 class DescriptorInfoMultiple |
54 : public DescriptorInfoMultipleMixin<DescriptorInfo> { | 51 : public DescriptorInfoMultipleMixin<DescriptorInfo> { |
55 public: | 52 public: |
56 explicit DescriptorInfoMultiple(intptr_t fd) | 53 explicit DescriptorInfoMultiple(intptr_t fd) |
57 : DescriptorInfoMultipleMixin(fd, false) {} | 54 : DescriptorInfoMultipleMixin(fd, false) {} |
58 virtual ~DescriptorInfoMultiple() {} | 55 virtual ~DescriptorInfoMultiple() {} |
59 | 56 |
60 private: | 57 private: |
61 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoMultiple); | 58 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoMultiple); |
62 }; | 59 }; |
63 | 60 |
64 | |
65 class EventHandlerImplementation { | 61 class EventHandlerImplementation { |
66 public: | 62 public: |
67 EventHandlerImplementation(); | 63 EventHandlerImplementation(); |
68 ~EventHandlerImplementation(); | 64 ~EventHandlerImplementation(); |
69 | 65 |
70 void UpdateEpollInstance(intptr_t old_mask, DescriptorInfo* di); | 66 void UpdateEpollInstance(intptr_t old_mask, DescriptorInfo* di); |
71 | 67 |
72 // Gets the socket data structure for a given file | 68 // Gets the socket data structure for a given file |
73 // descriptor. Creates a new one if one is not found. | 69 // descriptor. Creates a new one if one is not found. |
74 DescriptorInfo* GetDescriptorInfo(intptr_t fd, bool is_listening); | 70 DescriptorInfo* GetDescriptorInfo(intptr_t fd, bool is_listening); |
(...skipping 18 matching lines...) Expand all Loading... |
93 int epoll_fd_; | 89 int epoll_fd_; |
94 int timer_fd_; | 90 int timer_fd_; |
95 | 91 |
96 DISALLOW_COPY_AND_ASSIGN(EventHandlerImplementation); | 92 DISALLOW_COPY_AND_ASSIGN(EventHandlerImplementation); |
97 }; | 93 }; |
98 | 94 |
99 } // namespace bin | 95 } // namespace bin |
100 } // namespace dart | 96 } // namespace dart |
101 | 97 |
102 #endif // RUNTIME_BIN_EVENTHANDLER_LINUX_H_ | 98 #endif // RUNTIME_BIN_EVENTHANDLER_LINUX_H_ |
OLD | NEW |