Synchronous concurrency: Difference between revisions

Updated to work with Nim 1.4: replaced “nil” with “""” and “msg == nil” with “msg.len == 0”. Also, removed the explicit opening and closing of the file.
(→‎Using coroutines: Use forEachLine over useLines; No need to close the file.)
(Updated to work with Nim 1.4: replaced “nil” with “""” and “msg == nil” with “msg.len == 0”. Also, removed the explicit opening and closing of the file.)
Line 1,715:
 
proc read() {.thread.} =
varfor fileline =in open(FILE).lines:
for line in file.lines:
msgs.send(line)
msgs.send(nil"")
file.close()
echo count.recv()
count.close()
Line 1,727 ⟶ 1,725:
while true:
var msg = msgs.recv()
if msg.len == nil0:
break
echo msg
Anonymous user