favor 'select' over 'poll' on Genode (#6821)
The 'poll' of the Genode C runtime is a wrapper over 'select'.
This commit is contained in:
parent
6a101c5004
commit
3181f3b04c
2 changed files with 17 additions and 13 deletions
|
|
@ -279,8 +279,9 @@ proc updateHandle*[T](s: Selector[T], fd: SocketHandle,
|
||||||
inc(s.count)
|
inc(s.count)
|
||||||
pkey.events = events
|
pkey.events = events
|
||||||
|
|
||||||
proc unregister*[T](s: Selector[T], fd: SocketHandle) =
|
proc unregister*[T](s: Selector[T], fd: SocketHandle|int) =
|
||||||
s.withSelectLock():
|
s.withSelectLock():
|
||||||
|
let fd = fd.SocketHandle
|
||||||
var pkey = s.getKey(fd)
|
var pkey = s.getKey(fd)
|
||||||
if Event.Read in pkey.events:
|
if Event.Read in pkey.events:
|
||||||
IOFD_CLR(fd, addr s.rSet)
|
IOFD_CLR(fd, addr s.rSet)
|
||||||
|
|
@ -438,16 +439,17 @@ template withData*[T](s: Selector[T], fd: SocketHandle|int, value,
|
||||||
body1, body2: untyped) =
|
body1, body2: untyped) =
|
||||||
mixin withSelectLock
|
mixin withSelectLock
|
||||||
s.withSelectLock():
|
s.withSelectLock():
|
||||||
var value: ptr T
|
block:
|
||||||
let fdi = int(fd)
|
var value: ptr T
|
||||||
var i = 0
|
let fdi = int(fd)
|
||||||
while i < FD_SETSIZE:
|
var i = 0
|
||||||
if s.fds[i].ident == fdi:
|
while i < FD_SETSIZE:
|
||||||
value = addr(s.fds[i].data)
|
if s.fds[i].ident == fdi:
|
||||||
break
|
value = addr(s.fds[i].data)
|
||||||
inc(i)
|
break
|
||||||
if i != FD_SETSIZE:
|
inc(i)
|
||||||
body1
|
if i != FD_SETSIZE:
|
||||||
else:
|
body1
|
||||||
body2
|
else:
|
||||||
|
body2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,8 @@ else:
|
||||||
include ioselects/ioselectors_select
|
include ioselects/ioselectors_select
|
||||||
elif defined(solaris):
|
elif defined(solaris):
|
||||||
include ioselects/ioselectors_poll # need to replace it with event ports
|
include ioselects/ioselectors_poll # need to replace it with event ports
|
||||||
|
elif defined(genode):
|
||||||
|
include ioselects/ioselectors_select # TODO: use the native VFS layer
|
||||||
else:
|
else:
|
||||||
include ioselects/ioselectors_poll
|
include ioselects/ioselectors_poll
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue