Android-cuttlefish cvd tool
fdevent_epoll.h
Go to the documentation of this file.
1#pragma once
2
3/*
4 * Copyright (C) 2019 The Android Open Source Project
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#if defined(__linux__)
20
21#include "sysdeps.h"
22
23#include <sys/epoll.h>
24
25#include <deque>
26#include <list>
27#include <mutex>
28#include <unordered_map>
29
31
32#include "adb_unique_fd.h"
33#include "fdevent.h"
34
35struct fdevent_context_epoll final : public fdevent_context {
36 fdevent_context_epoll();
37 virtual ~fdevent_context_epoll();
38
39 virtual void Register(fdevent* fde) final;
40 virtual void Unregister(fdevent* fde) final;
41
42 virtual void Set(fdevent* fde, unsigned events) final;
43
44 virtual void Loop() final;
45 size_t InstalledCount() final;
46
47 protected:
48 virtual void Interrupt() final;
49
50 private:
51 unique_fd epoll_fd_;
52 unique_fd interrupt_fd_;
53 fdevent* interrupt_fde_ = nullptr;
54};
55
56#endif // defined(__linux__)
Definition: unique_fd.h:61
Definition: fdevent.h:70
virtual void Loop()=0
virtual void Register(fdevent *)=0
virtual void Unregister(fdevent *)=0
virtual void Set(fdevent *fde, unsigned events)=0
Definition: fdevent.h:57