v2 / vlib / os / notify / notify.v
36 lines · 31 sloc · 527 bytes · 83b4167c192a170c60db552b004161449fb3043b
Raw
1module notify
2
3import time
4
5// Backends should provide a `new()?FdNotifier` function
6pub interface FdNotifier {
7mut:
8 add(fd int, events FdEventType, conf ...FdConfigFlags) !
9 modify(fd int, events FdEventType, conf ...FdConfigFlags) !
10 remove(fd int) !
11 wait(timeout time.Duration) []FdEvent
12 close() !
13}
14
15pub interface FdEvent {
16 fd int
17 kind FdEventType
18}
19
20@[flag]
21pub enum FdEventType {
22 read
23 write
24 peer_hangup
25 exception
26 error
27 hangup
28}
29
30@[flag]
31pub enum FdConfigFlags {
32 edge_trigger
33 one_shot
34 wake_up
35 exclusive
36}
37