Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
eventhandler_macos.h
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_BIN_EVENTHANDLER_MACOS_H_
6#define RUNTIME_BIN_EVENTHANDLER_MACOS_H_
7
8#if !defined(RUNTIME_BIN_EVENTHANDLER_H_)
9#error Do not include eventhandler_macos.h directly; use eventhandler.h instead.
10#endif
11
12#include <errno.h>
13#include <sys/event.h> // NOLINT
14#include <sys/socket.h>
15#include <unistd.h>
16
17#include "platform/hashmap.h"
19
20namespace dart {
21namespace bin {
22
23class DescriptorInfo : public DescriptorInfoBase {
24 public:
27
28 virtual ~DescriptorInfo() {}
29
30 intptr_t GetPollEvents();
31
32 virtual void Close() {
33 close(fd_);
34 fd_ = -1;
35 }
36
38
40
42
44
45 protected:
47
48 private:
50};
51
52class DescriptorInfoSingle : public DescriptorInfoSingleMixin<DescriptorInfo> {
53 public:
57
58 private:
60};
61
62class DescriptorInfoMultiple
63 : public DescriptorInfoMultipleMixin<DescriptorInfo> {
64 public:
68
69 private:
71};
72
73class EventHandlerImplementation {
74 public:
77
78 void UpdateKQueueInstance(intptr_t old_mask, DescriptorInfo* di);
79
80 // Gets the socket data structure for a given file
81 // descriptor. Creates a new one if one is not found.
82 DescriptorInfo* GetDescriptorInfo(intptr_t fd, bool is_listening);
83 void SendData(intptr_t id, Dart_Port dart_port, int64_t data);
84 void Start(EventHandler* handler);
85 void Shutdown();
86
87 private:
88 int64_t GetTimeout();
89 void HandleEvents(struct kevent* events, int size);
90 void HandleTimeout();
91 static void EventHandlerEntry(uword args);
92 void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data);
93 void HandleInterruptFd();
94 void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask);
95 intptr_t GetEvents(struct kevent* event, DescriptorInfo* di);
96 static void* GetHashmapKeyFromFd(intptr_t fd);
97 static uint32_t GetHashmapHashFromFd(intptr_t fd);
98
99 SimpleHashMap socket_map_;
100 TimeoutQueue timeout_queue_;
101 bool shutdown_;
102 int interrupt_fds_[2];
103 int kqueue_fd_;
104
106};
107
108} // namespace bin
109} // namespace dart
110
111#endif // RUNTIME_BIN_EVENTHANDLER_MACOS_H_
void set_tracked_by_kqueue(bool value)
void SendData(intptr_t id, Dart_Port dart_port, int64_t data)
void Start(EventHandler *handler)
DescriptorInfo * GetDescriptorInfo(intptr_t fd, bool is_listening)
void UpdateKQueueInstance(intptr_t old_mask, DescriptorInfo *di)
int64_t Dart_Port
Definition dart_api.h:1524
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent * event
uint8_t value
uintptr_t uword
Definition globals.h:501
static int8_t data[kExtLength]
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581