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_H_ | 5 #ifndef RUNTIME_BIN_EVENTHANDLER_H_ |
6 #define RUNTIME_BIN_EVENTHANDLER_H_ | 6 #define RUNTIME_BIN_EVENTHANDLER_H_ |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/dartutils.h" | 9 #include "bin/dartutils.h" |
10 #include "bin/isolate_data.h" | 10 #include "bin/isolate_data.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 void UpdateTimeout(Dart_Port port, int64_t timeout); | 105 void UpdateTimeout(Dart_Port port, int64_t timeout); |
106 | 106 |
107 private: | 107 private: |
108 Timeout* next_timeout_; | 108 Timeout* next_timeout_; |
109 Timeout* timeouts_; | 109 Timeout* timeouts_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(TimeoutQueue); | 111 DISALLOW_COPY_AND_ASSIGN(TimeoutQueue); |
112 }; | 112 }; |
113 | 113 |
114 | |
115 class InterruptMessage { | 114 class InterruptMessage { |
116 public: | 115 public: |
117 intptr_t id; | 116 intptr_t id; |
118 Dart_Port dart_port; | 117 Dart_Port dart_port; |
119 int64_t data; | 118 int64_t data; |
120 }; | 119 }; |
121 | 120 |
122 | |
123 static const int kInterruptMessageSize = sizeof(InterruptMessage); | 121 static const int kInterruptMessageSize = sizeof(InterruptMessage); |
124 static const int kInfinityTimeout = -1; | 122 static const int kInfinityTimeout = -1; |
125 static const int kTimerId = -1; | 123 static const int kTimerId = -1; |
126 static const int kShutdownId = -2; | 124 static const int kShutdownId = -2; |
127 | 125 |
128 | |
129 template <typename T> | 126 template <typename T> |
130 class CircularLinkedList { | 127 class CircularLinkedList { |
131 public: | 128 public: |
132 CircularLinkedList() : head_(NULL) {} | 129 CircularLinkedList() : head_(NULL) {} |
133 | 130 |
134 typedef void (*ClearFun)(void* value); | 131 typedef void (*ClearFun)(void* value); |
135 | 132 |
136 // Returns true if the list was empty. | 133 // Returns true if the list was empty. |
137 bool Add(T t) { | 134 bool Add(T t) { |
138 Entry* e = new Entry(t); | 135 Entry* e = new Entry(t); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 const T t; | 219 const T t; |
223 Entry* next_; | 220 Entry* next_; |
224 Entry* prev_; | 221 Entry* prev_; |
225 }; | 222 }; |
226 | 223 |
227 Entry* head_; | 224 Entry* head_; |
228 | 225 |
229 DISALLOW_COPY_AND_ASSIGN(CircularLinkedList); | 226 DISALLOW_COPY_AND_ASSIGN(CircularLinkedList); |
230 }; | 227 }; |
231 | 228 |
232 | |
233 class DescriptorInfoBase { | 229 class DescriptorInfoBase { |
234 public: | 230 public: |
235 explicit DescriptorInfoBase(intptr_t fd) : fd_(fd) { ASSERT(fd_ != -1); } | 231 explicit DescriptorInfoBase(intptr_t fd) : fd_(fd) { ASSERT(fd_ != -1); } |
236 | 232 |
237 virtual ~DescriptorInfoBase() {} | 233 virtual ~DescriptorInfoBase() {} |
238 | 234 |
239 // The OS descriptor. | 235 // The OS descriptor. |
240 intptr_t fd() { return fd_; } | 236 intptr_t fd() { return fd_; } |
241 | 237 |
242 // Whether this descriptor refers to an underlying listening OS socket. | 238 // Whether this descriptor refers to an underlying listening OS socket. |
(...skipping 27 matching lines...) Expand all Loading... |
270 // Closes this descriptor. | 266 // Closes this descriptor. |
271 virtual void Close() = 0; | 267 virtual void Close() = 0; |
272 | 268 |
273 protected: | 269 protected: |
274 intptr_t fd_; | 270 intptr_t fd_; |
275 | 271 |
276 private: | 272 private: |
277 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoBase); | 273 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoBase); |
278 }; | 274 }; |
279 | 275 |
280 | |
281 // Describes a OS descriptor (e.g. file descriptor on linux or HANDLE on | 276 // Describes a OS descriptor (e.g. file descriptor on linux or HANDLE on |
282 // windows) which is connected to a single Dart_Port. | 277 // windows) which is connected to a single Dart_Port. |
283 // | 278 // |
284 // Subclasses of this class can be e.g. connected tcp sockets. | 279 // Subclasses of this class can be e.g. connected tcp sockets. |
285 template <typename DI> | 280 template <typename DI> |
286 class DescriptorInfoSingleMixin : public DI { | 281 class DescriptorInfoSingleMixin : public DI { |
287 private: | 282 private: |
288 static const int kTokenCount = 16; | 283 static const int kTokenCount = 16; |
289 | 284 |
290 public: | 285 public: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 355 |
361 private: | 356 private: |
362 Dart_Port port_; | 357 Dart_Port port_; |
363 int tokens_; | 358 int tokens_; |
364 intptr_t mask_; | 359 intptr_t mask_; |
365 bool disable_tokens_; | 360 bool disable_tokens_; |
366 | 361 |
367 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoSingleMixin); | 362 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoSingleMixin); |
368 }; | 363 }; |
369 | 364 |
370 | |
371 // Describes a OS descriptor (e.g. file descriptor on linux or HANDLE on | 365 // Describes a OS descriptor (e.g. file descriptor on linux or HANDLE on |
372 // windows) which is connected to multiple Dart_Port's. | 366 // windows) which is connected to multiple Dart_Port's. |
373 // | 367 // |
374 // Subclasses of this class can be e.g. a listening socket which multiple | 368 // Subclasses of this class can be e.g. a listening socket which multiple |
375 // isolates are listening on. | 369 // isolates are listening on. |
376 template <typename DI> | 370 template <typename DI> |
377 class DescriptorInfoMultipleMixin : public DI { | 371 class DescriptorInfoMultipleMixin : public DI { |
378 private: | 372 private: |
379 static const int kTokenCount = 4; | 373 static const int kTokenCount = 4; |
380 | 374 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 friend class EventHandlerImplementation; | 647 friend class EventHandlerImplementation; |
654 EventHandlerImplementation delegate_; | 648 EventHandlerImplementation delegate_; |
655 | 649 |
656 DISALLOW_COPY_AND_ASSIGN(EventHandler); | 650 DISALLOW_COPY_AND_ASSIGN(EventHandler); |
657 }; | 651 }; |
658 | 652 |
659 } // namespace bin | 653 } // namespace bin |
660 } // namespace dart | 654 } // namespace dart |
661 | 655 |
662 #endif // RUNTIME_BIN_EVENTHANDLER_H_ | 656 #endif // RUNTIME_BIN_EVENTHANDLER_H_ |
OLD | NEW |