Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: runtime/bin/eventhandler_macos.h

Issue 8431027: Some Linux and Mac OS event handler refactoring (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager£ Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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_MACOS_H_ 5 #ifndef BIN_EVENTHANDLER_MACOS_H_
6 #define BIN_EVENTHANDLER_MACOS_H_ 6 #define BIN_EVENTHANDLER_MACOS_H_
7 7
8 8
9 typedef struct { 9 class InterruptMessage {
10 public:
10 intptr_t id; 11 intptr_t id;
11 Dart_Port dart_port; 12 Dart_Port dart_port;
12 int64_t data; 13 int64_t data;
13 } InterruptMessage; 14 };
14 15
15 16
16 typedef struct { 17 class SocketData {
17 Dart_Port dart_port; 18 public:
18 intptr_t mask; 19 void FillPollEvents(struct pollfd* pollfds);
19 } PortData; 20 bool IsListeningSocket() { return (_mask & (1 << kListeningSocket)) != 0; }
21
22 Dart_Port port() { return _port; }
23 void set_port(Dart_Port port) { _port = port; }
24 intptr_t mask() { return _mask; }
25 void set_mask(intptr_t mask) { _mask = mask; }
26
27 private:
28 Dart_Port _port;
29 intptr_t _mask;
30 };
20 31
21 32
22 class EventHandlerImplementation { 33 class EventHandlerImplementation {
23 public: 34 public:
24 EventHandlerImplementation(); 35 EventHandlerImplementation();
25 ~EventHandlerImplementation(); 36 ~EventHandlerImplementation();
26 37
38 SocketData* GetSocketData(intptr_t fd);
27 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data); 39 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data);
28 void StartEventHandler(); 40 void StartEventHandler();
29 41
30 private: 42 private:
31 intptr_t GetTimeout(); 43 intptr_t GetTimeout();
32 bool GetInterruptMessage(InterruptMessage* msg); 44 bool GetInterruptMessage(InterruptMessage* msg);
33 struct pollfd* GetPollFds(intptr_t* size); 45 struct pollfd* GetPollFds(intptr_t* size);
34 void RegisterFdWakeup(intptr_t id, Dart_Port dart_port, intptr_t data); 46 void RegisterFdWakeup(intptr_t id, Dart_Port dart_port, intptr_t data);
35 void UnregisterFdWakeup(intptr_t id); 47 void UnregisterFdWakeup(intptr_t id);
36 void CloseFd(intptr_t id); 48 void CloseFd(intptr_t id);
37 void UnregisterFd(intptr_t id); 49 void UnregisterFd(intptr_t id);
38 void HandleEvents(struct pollfd* pollfds, int pollfds_size, int result_size); 50 void HandleEvents(struct pollfd* pollfds, int pollfds_size, int result_size);
39 void HandleTimeout(); 51 void HandleTimeout();
40 static void* Poll(void* args); 52 static void* Poll(void* args);
41 void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data); 53 void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data);
42 void HandleInterruptFd(); 54 void HandleInterruptFd();
43 void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask); 55 void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask);
44 Dart_Port PortFor(intptr_t fd);
45 bool IsListeningSocket(intptr_t fd);
46 intptr_t GetPollEvents(struct pollfd* pollfd); 56 intptr_t GetPollEvents(struct pollfd* pollfd);
47 void SetPollEvents(struct pollfd* pollfds, intptr_t mask);
48 57
49 PortData* port_map_; 58 SocketData* socket_map_;
50 intptr_t port_map_entries_; 59 intptr_t socket_map_entries_;
51 intptr_t port_map_size_; 60 intptr_t socket_map_size_;
52 int64_t timeout_; // Time for next timeout. 61 int64_t timeout_; // Time for next timeout.
53 Dart_Port timeout_port_; 62 Dart_Port timeout_port_;
54 int interrupt_fds_[2]; 63 int interrupt_fds_[2];
55 }; 64 };
56 65
57 66
58 #endif // BIN_EVENTHANDLER_MACOS_H_ 67 #endif // BIN_EVENTHANDLER_MACOS_H_
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698