Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/core/kernel/src/wasm/posix/epoll.ts
1068 views
1
/*
2
3
See https://en.wikipedia.org/wiki/Epoll
4
5
This is a stub implementation of epoll that doesn't do anything in terms
6
of actually detecting file changes, but also appears not broken to the user.
7
It's very reasonable that we could implement a real version of epoll.
8
For linux it could just be a lightweight wrapper around real epoll, and for
9
other environments, something else depending on constraints.
10
11
This is used by the tail coreutils command to watch a file...
12
*/
13
14
export default function epoll({ sleep }: { sleep? }) {
15
return {
16
// int epoll_create(int flags);
17
epoll_create: (_size: number): number => {
18
return 0;
19
},
20
// int epoll_create1(int flags);
21
epoll_create1: (_flags: number): number => {
22
return 0;
23
},
24
25
// int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
26
epoll_ctl: (
27
_epfd: number,
28
_op: number,
29
_fd: number,
30
_epoll_event_ptr: number
31
): number => {
32
return 0;
33
},
34
35
// int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout);
36
epoll_wait: (
37
_epfd: number,
38
_epoll_event_ptr: number,
39
_maxevents: number,
40
timeout: number
41
): number => {
42
// if blocking sleep is available, we wait timeout *milliseconds*, then return 0
43
sleep?.(timeout);
44
return 0;
45
},
46
};
47
}
48
49