mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
picoev: remove fmt off tags (#20569)
This commit is contained in:
parent
43e96ce5bb
commit
43fd568874
4 changed files with 34 additions and 28 deletions
|
@ -76,13 +76,14 @@ fn (mut pv Picoev) poll_once(max_wait_in_sec int) int {
|
||||||
// Iterates through file descriptors and calls their callbacks for triggered events
|
// Iterates through file descriptors and calls their callbacks for triggered events
|
||||||
for target in pv.file_descriptors {
|
for target in pv.file_descriptors {
|
||||||
if target.loop_id == pv.loop.id {
|
if target.loop_id == pv.loop.id {
|
||||||
// vfmt off
|
mut read_events := 0
|
||||||
read_events := (
|
if C.FD_ISSET(target.fd, &readfds) != 0 {
|
||||||
(if C.FD_ISSET(target.fd, &readfds) != 0 { picoev_read } else { 0 })
|
read_events |= picoev_read
|
||||||
|
|
}
|
||||||
(if C.FD_ISSET(target.fd, &writefds) != 0 { picoev_write } else { 0 })
|
if C.FD_ISSET(target.fd, &writefds) != 0 {
|
||||||
)
|
read_events |= picoev_write
|
||||||
// vfmt on
|
}
|
||||||
|
|
||||||
if read_events != 0 {
|
if read_events != 0 {
|
||||||
$if trace_fd ? {
|
$if trace_fd ? {
|
||||||
eprintln('do callback ${target.fd}')
|
eprintln('do callback ${target.fd}')
|
||||||
|
|
|
@ -51,13 +51,15 @@ pub fn create_kqueue_loop(id int) !&KqueueLoop {
|
||||||
// ev_set sets a new `kevent` with file descriptor `index`
|
// ev_set sets a new `kevent` with file descriptor `index`
|
||||||
@[inline]
|
@[inline]
|
||||||
pub fn (mut pv Picoev) ev_set(index int, operation int, events int) {
|
pub fn (mut pv Picoev) ev_set(index int, operation int, events int) {
|
||||||
// vfmt off
|
mut filter := 0
|
||||||
filter := i16(
|
if events & picoev_read != 0 {
|
||||||
(if events & picoev_read != 0 { C.EVFILT_READ } else { 0 })
|
filter |= C.EVFILT_READ
|
||||||
|
|
}
|
||||||
(if events & picoev_write != 0 { C.EVFILT_WRITE } else { 0 })
|
if events & picoev_write != 0 {
|
||||||
)
|
filter |= C.EVFILT_WRITE
|
||||||
// vfmt on
|
}
|
||||||
|
filter = i16(filter)
|
||||||
|
|
||||||
C.EV_SET(&pv.loop.changelist[index], pv.loop.changed_fds, filter, operation, 0, 0,
|
C.EV_SET(&pv.loop.changelist[index], pv.loop.changed_fds, filter, operation, 0, 0,
|
||||||
0)
|
0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,13 +116,14 @@ fn (mut pv Picoev) poll_once(max_wait_in_sec int) int {
|
||||||
assert event.data.fd < max_fds
|
assert event.data.fd < max_fds
|
||||||
}
|
}
|
||||||
if pv.loop.id == target.loop_id && target.events & picoev_readwrite != 0 {
|
if pv.loop.id == target.loop_id && target.events & picoev_readwrite != 0 {
|
||||||
// vfmt off
|
mut read_events := 0
|
||||||
read_events := (
|
if event.events & u32(C.EPOLLIN) != 0 {
|
||||||
(if event.events & u32(C.EPOLLIN) != 0 { picoev_read } else { 0 })
|
read_events |= picoev_read
|
||||||
|
|
}
|
||||||
(if event.events & u32(C.EPOLLOUT) != 0 { picoev_write } else { 0 })
|
if event.events & u32(C.EPOLLOUT) != 0 {
|
||||||
)
|
read_events |= picoev_write
|
||||||
// vfmt on
|
}
|
||||||
|
|
||||||
if read_events != 0 {
|
if read_events != 0 {
|
||||||
// do callback!
|
// do callback!
|
||||||
unsafe { target.cb(event.data.fd, read_events, &pv) }
|
unsafe { target.cb(event.data.fd, read_events, &pv) }
|
||||||
|
|
|
@ -51,13 +51,15 @@ pub fn create_kqueue_loop(id int) !&KqueueLoop {
|
||||||
// ev_set sets a new `kevent` with file descriptor `index`
|
// ev_set sets a new `kevent` with file descriptor `index`
|
||||||
@[inline]
|
@[inline]
|
||||||
pub fn (mut pv Picoev) ev_set(index int, operation int, events int) {
|
pub fn (mut pv Picoev) ev_set(index int, operation int, events int) {
|
||||||
// vfmt off
|
mut filter := 0
|
||||||
filter := i16(
|
if events & picoev_read != 0 {
|
||||||
(if events & picoev_read != 0 { C.EVFILT_READ } else { 0 })
|
filter |= C.EVFILT_READ
|
||||||
|
|
}
|
||||||
(if events & picoev_write != 0 { C.EVFILT_WRITE } else { 0 })
|
if events & picoev_write != 0 {
|
||||||
)
|
filter |= C.EVFILT_WRITE
|
||||||
// vfmt on
|
}
|
||||||
|
filter = i16(filter)
|
||||||
|
|
||||||
C.EV_SET(&pv.loop.changelist[index], pv.loop.changed_fds, filter, operation, 0, 0,
|
C.EV_SET(&pv.loop.changelist[index], pv.loop.changed_fds, filter, operation, 0, 0,
|
||||||
0)
|
0)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue