Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
BaseEventLoop.h
浏览该文件的文档.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
21#pragma once
22
24
25#include <cstdint>
26
27namespace sese::event {
28
31public:
32 virtual bool init() = 0;
33
34 virtual ~BaseEventLoop() = default;
35
36 virtual void dispatch(uint32_t timeout) = 0;
37
38 virtual void onAccept(int fd) = 0;
39
40 virtual void onRead(BaseEvent *event) = 0;
41
42 virtual void onWrite(BaseEvent *event) = 0;
43
44 virtual void onError(BaseEvent *event) = 0;
45
46 virtual void onClose(BaseEvent *event) = 0;
47
48 virtual BaseEvent *createEvent(int fd, unsigned int events, void *data) = 0;
49
50 virtual void freeEvent(BaseEvent *event) = 0;
51
52 virtual bool setEvent(BaseEvent *event) = 0;
53
54 virtual void setListenFd(int fd) = 0;
55
56protected:
58 bool handleClose = true;
59};
60
61} // namespace sese::event