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_H_ | 5 #ifndef BIN_EVENTHANDLER_H_ |
6 #define BIN_EVENTHANDLER_H_ | 6 #define BIN_EVENTHANDLER_H_ |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/isolate_data.h" | 9 #include "bin/isolate_data.h" |
10 #include "bin/socket.h" | |
11 | 10 |
12 namespace dart { | 11 namespace dart { |
13 namespace bin { | 12 namespace bin { |
14 | 13 |
15 // Flags used to provide information and actions to the eventhandler | 14 // Flags used to provide information and actions to the eventhandler |
16 // when sending a message about a file descriptor. These flags should | 15 // when sending a message about a file descriptor. These flags should |
17 // be kept in sync with the constants in socket_impl.dart. For more | 16 // be kept in sync with the constants in socket_impl.dart. For more |
18 // information see the comments in socket_impl.dart | 17 // information see the comments in socket_impl.dart |
19 enum MessageFlags { | 18 enum MessageFlags { |
20 kInEvent = 0, | 19 kInEvent = 0, |
21 kOutEvent = 1, | 20 kOutEvent = 1, |
22 kErrorEvent = 2, | 21 kErrorEvent = 2, |
23 kCloseEvent = 3, | 22 kCloseEvent = 3, |
24 kDestroyedEvent = 4, | 23 kDestroyedEvent = 4, |
25 kCloseCommand = 8, | 24 kCloseCommand = 8, |
26 kShutdownReadCommand = 9, | 25 kShutdownReadCommand = 9, |
27 kShutdownWriteCommand = 10, | 26 kShutdownWriteCommand = 10, |
| 27 kReturnTokenCommand = 11, |
28 kListeningSocket = 16, | 28 kListeningSocket = 16, |
29 kPipe = 17, | 29 kPipe = 17, |
30 }; | 30 }; |
31 | 31 |
32 | 32 |
33 class TimeoutQueue { | 33 class TimeoutQueue { |
34 private: | 34 private: |
35 class Timeout { | 35 class Timeout { |
36 public: | 36 public: |
37 Timeout(Dart_Port port, int64_t timeout, Timeout* next) | 37 Timeout(Dart_Port port, int64_t timeout, Timeout* next) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 #else | 101 #else |
102 #error Unknown target os. | 102 #error Unknown target os. |
103 #endif | 103 #endif |
104 | 104 |
105 namespace dart { | 105 namespace dart { |
106 namespace bin { | 106 namespace bin { |
107 | 107 |
108 class EventHandler { | 108 class EventHandler { |
109 public: | 109 public: |
110 void SendData(intptr_t id, Dart_Port dart_port, int64_t data) { | 110 void SendData(intptr_t id, Dart_Port dart_port, int64_t data) { |
111 delegate_.Notify(id, dart_port, data); | 111 delegate_.SendData(id, dart_port, data); |
112 } | 112 } |
113 | 113 |
114 /** | 114 /** |
115 * Start the event-handler. | 115 * Start the event-handler. |
116 */ | 116 */ |
117 static void Start(); | 117 static void Start(); |
118 | 118 |
119 /** | 119 /** |
120 * Stop the event-handler. It's expected that there will be no further calls | 120 * Stop the event-handler. It's expected that there will be no further calls |
121 * to SendData after a call to Stop. | 121 * to SendData after a call to Stop. |
122 */ | 122 */ |
123 static void Stop(); | 123 static void Stop(); |
124 | 124 |
125 static EventHandlerImplementation* delegate(); | 125 static EventHandlerImplementation* delegate(); |
126 | 126 |
127 private: | 127 private: |
128 friend class EventHandlerImplementation; | 128 friend class EventHandlerImplementation; |
129 EventHandlerImplementation delegate_; | 129 EventHandlerImplementation delegate_; |
130 }; | 130 }; |
131 | 131 |
132 } // namespace bin | 132 } // namespace bin |
133 } // namespace dart | 133 } // namespace dart |
134 | 134 |
135 #endif // BIN_EVENTHANDLER_H_ | 135 #endif // BIN_EVENTHANDLER_H_ |
OLD | NEW |