Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
eventhandler_linux.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_LINUX_H_
6#define RUNTIME_BIN_EVENTHANDLER_LINUX_H_
7
8#if !defined(RUNTIME_BIN_EVENTHANDLER_H_)
9#error Do not include eventhandler_linux.h directly; use eventhandler.h instead.
10#endif
11
12#include <errno.h>
13#include <sys/epoll.h>
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:
25 explicit DescriptorInfo(intptr_t fd) : DescriptorInfoBase(fd) {}
26
27 virtual ~DescriptorInfo() {}
28
29 intptr_t GetPollEvents();
30
31 virtual void Close() {
32 close(fd_);
33 fd_ = -1;
34 }
35
36 private:
38};
39
40class DescriptorInfoSingle : public DescriptorInfoSingleMixin<DescriptorInfo> {
41 public:
45
46 private:
48};
49
50class DescriptorInfoMultiple
51 : public DescriptorInfoMultipleMixin<DescriptorInfo> {
52 public:
56
57 private:
59};
60
61class EventHandlerImplementation {
62 public:
65
66 void UpdateEpollInstance(intptr_t old_mask, DescriptorInfo* di);
67
68 // Gets the socket data structure for a given file
69 // descriptor. Creates a new one if one is not found.
70 DescriptorInfo* GetDescriptorInfo(intptr_t fd, bool is_listening);
71 void SendData(intptr_t id, Dart_Port dart_port, int64_t data);
72 void Start(EventHandler* handler);
73 void Shutdown();
74
75 private:
76 void HandleEvents(struct epoll_event* events, int size);
77 static void Poll(uword args);
78 void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data);
79 void HandleInterruptFd();
80 void UpdateTimerFd();
81 void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask);
82 intptr_t GetPollEvents(intptr_t events, DescriptorInfo* di);
83 static void* GetHashmapKeyFromFd(intptr_t fd);
84 static uint32_t GetHashmapHashFromFd(intptr_t fd);
85
86 SimpleHashMap socket_map_;
87 TimeoutQueue timeout_queue_;
88 bool shutdown_;
89 int interrupt_fds_[2];
90 int epoll_fd_;
91 int timer_fd_;
92
94};
95
96} // namespace bin
97} // namespace dart
98
99#endif // RUNTIME_BIN_EVENTHANDLER_LINUX_H_
void SendData(intptr_t id, Dart_Port dart_port, int64_t data)
void UpdateEpollInstance(intptr_t old_mask, DescriptorInfo *di)
void Start(EventHandler *handler)
DescriptorInfo * GetDescriptorInfo(intptr_t fd, bool is_listening)
int64_t Dart_Port
Definition dart_api.h:1524
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uintptr_t uword
Definition globals.h:501
static int8_t data[kExtLength]
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581