[std/channels]fix recv leaks(Part One) (#17394)

This commit is contained in:
flywind
2021-03-17 17:08:54 +08:00
committed by GitHub
parent bebf2ce24a
commit e9b5543bd5
3 changed files with 9 additions and 26 deletions

View File

@@ -89,6 +89,7 @@ proc runSuite(
capacity(chan) == 1
isBuffered(chan) == false
isUnbuffered(chan) == true
else:
chan = allocChannel(size = int.sizeof.int, n = 7)
check:
@@ -109,7 +110,7 @@ proc runSuite(
discard pthread_join(threads[0], nil)
discard pthread_join(threads[1], nil)
freeChannel(chan)
freeChannel(chan)
# ----------------------------------------------------------------------------------

View File

@@ -24,8 +24,7 @@ var worker1: Thread[void]
createThread(worker1, firstWorker)
# Block until the message arrives, then print it out.
var dest = ""
chan.recv(dest)
let dest = chan.recv()
doAssert dest == "Hello World!"
# Wait for the thread to exit before moving on to the next example.