tasyncawait now works on Linux.
Reworked detection of a file descriptor being closed with epoll (in the case of sockets it is when the remote host disconnects). Ensured that events are only updated when they change.
This commit is contained in:
parent
9b5357da5a
commit
2ce07042fd
3 changed files with 69 additions and 45 deletions
|
|
@ -15,24 +15,17 @@ const
|
|||
var clientCount = 0
|
||||
|
||||
proc sendMessages(disp: PDispatcher, client: TSocketHandle): PFuture[int] {.async.} =
|
||||
echo("entering sendMessages")
|
||||
for i in 0 .. <messagesToSend:
|
||||
discard await disp.send(client, "Message " & $i & "\c\L")
|
||||
echo("returning sendMessages")
|
||||
|
||||
proc launchSwarm(disp: PDispatcher, port: TPort): PFuture[int] {.async.} =
|
||||
for i in 0 .. <swarmSize:
|
||||
var sock = socket()
|
||||
# TODO: We may need to explicitly register and unregister the fd.
|
||||
# This is because when the socket is closed, selectors is not aware
|
||||
# that it has been closed. While epoll is. Perhaps we should just unregister
|
||||
# in close()?
|
||||
echo(sock.cint)
|
||||
|
||||
#disp.register(sock)
|
||||
discard await disp.connect(sock, "localhost", port)
|
||||
when true:
|
||||
discard await sendMessages(disp, sock)
|
||||
echo("Calling close")
|
||||
sock.close()
|
||||
else:
|
||||
# Issue #932: https://github.com/Araq/Nimrod/issues/932
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue