picoev: extract common code to a trace_fd/1 function, cleanup

This commit is contained in:
Delyan Angelov 2024-10-29 18:32:31 +02:00
parent 3939737a8d
commit 6e9a66dbf3
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
4 changed files with 22 additions and 83 deletions

View file

@ -83,18 +83,13 @@ fn (mut pv Picoev) poll_once(max_wait_in_sec int) int {
if C.FD_ISSET(target.fd, &writefds) != 0 {
read_events |= picoev_write
}
if read_events != 0 {
$if trace_fd ? {
eprintln('do callback ${target.fd}')
}
trace_fd('do callback ${target.fd}')
// do callback!
unsafe { target.cb(target.fd, read_events, &pv) }
}
}
}
}
return 0
}