2021-06-15 04:44:31 +03:00
|
|
|
module notify
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
2022-05-13 06:56:21 +03:00
|
|
|
// Backends should provide a `new()?FdNotifier` function
|
2021-06-15 04:44:31 +03:00
|
|
|
pub interface FdNotifier {
|
2021-10-11 15:41:31 +03:00
|
|
|
mut:
|
2022-10-16 09:28:57 +03:00
|
|
|
add(fd int, events FdEventType, conf ...FdConfigFlags) !
|
|
|
|
modify(fd int, events FdEventType, conf ...FdConfigFlags) !
|
|
|
|
remove(fd int) !
|
2021-06-15 04:44:31 +03:00
|
|
|
wait(timeout time.Duration) []FdEvent
|
2022-10-16 09:28:57 +03:00
|
|
|
close() !
|
2021-06-15 04:44:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pub interface FdEvent {
|
|
|
|
fd int
|
|
|
|
kind FdEventType
|
|
|
|
}
|
|
|
|
|
|
|
|
[flag]
|
|
|
|
pub enum FdEventType {
|
|
|
|
read
|
|
|
|
write
|
|
|
|
peer_hangup
|
|
|
|
exception
|
|
|
|
error
|
|
|
|
hangup
|
|
|
|
}
|
|
|
|
|
|
|
|
[flag]
|
|
|
|
pub enum FdConfigFlags {
|
|
|
|
edge_trigger
|
|
|
|
one_shot
|
|
|
|
wake_up
|
|
|
|
exclusive
|
|
|
|
}
|