1/*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
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 */
15
16#ifndef NSTACKX_EVENT_H
17#define NSTACKX_EVENT_H
18
19#include "sys_event.h"
20#include "nstackx_epoll.h"
21#include "nstackx_list.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27typedef void (*EventHandle)(void *arg);
28
29typedef struct EventNode {
30    List list;
31    EpollDesc epollfd;
32    PipeDesc pipeFd[PIPE_FD_NUM];
33    EpollTask task;
34} EventNode;
35
36NSTACKX_EXPORT int32_t PostEvent(const List *eventNodeChain, EpollDesc epollfd, EventHandle handle, void *arg);
37NSTACKX_EXPORT void ClearEvent(const List *eventNodeChain, EpollDesc epollfd);
38NSTACKX_EXPORT int32_t EventModuleInit(List *eventNodeChain, EpollDesc epollfd);
39NSTACKX_EXPORT void EventModuleClean(const List *eventNodeChain, EpollDesc epollfd);
40NSTACKX_EXPORT void EventNodeChainClean(List *eventNodeChain);
41NSTACKX_EXPORT EpollTask *GetEpollTask(List *eventNodeChain, EpollDesc epollfd);
42
43#ifdef __cplusplus
44}
45#endif
46
47#endif // NSTACKX_EVENT_H
48