diff options
author | Araq <rumpf_a@web.de> | 2011-07-16 18:34:18 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-07-16 18:34:18 +0200 |
commit | 42e6130b2c37345963c0b5469e12a287b88bf3eb (patch) | |
tree | 98a957645b04b43ddf86a7c499a8fc7d9cad69aa /tests/threads | |
parent | fe5df368c18c79ee76fb63cb64121e1f9c3946bc (diff) | |
download | Nim-42e6130b2c37345963c0b5469e12a287b88bf3eb.tar.gz |
first steps to explicit channels for thread communication; added mainThreadId
Diffstat (limited to 'tests/threads')
-rwxr-xr-x | tests/threads/threadex.nim | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/tests/threads/threadex.nim b/tests/threads/threadex.nim index 65056a954..d8b4a94fb 100755 --- a/tests/threads/threadex.nim +++ b/tests/threads/threadex.nim @@ -9,7 +9,6 @@ type var consumer: TThread[TMsg] - producer: TThread[int] printedLines = 0 proc consume() {.thread.} = @@ -21,7 +20,7 @@ proc consume() {.thread.} = echo x.data discard atomicInc(printedLines) -proc produce() {.thread.} = +proc produce() = var m: TMsg var input = open("readme.txt") while not endOfFile(input): @@ -30,15 +29,14 @@ proc produce() {.thread.} = consumer.send(m) close(input) m.k = mEof - m.backTo = myThreadId[int]() + m.backTo = mainThreadId[int]() consumer.send(m) var result = recv[int]() echo result createThread(consumer, consume) -createThread(producer, produce) +produce() joinThread(consumer) -joinThread(producer) echo printedLines |