diff options
author | Araq <rumpf_a@web.de> | 2011-11-25 17:26:11 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-11-25 17:26:11 +0100 |
commit | 02e8e9c3ea130882c50326ed83240e29eeffb854 (patch) | |
tree | 457e68f5b7081f92beb0f96077c921bdeafe9843 /tests | |
parent | 566c26bc2da7eeb03390ee4c0d7af3d8cafbc561 (diff) | |
download | Nim-02e8e9c3ea130882c50326ed83240e29eeffb854.tar.gz |
fixed bug that kept tls emulation from working
Diffstat (limited to 'tests')
-rw-r--r-- | tests/specials.nim | 2 | ||||
-rwxr-xr-x | tests/threads/threadex.nim | 31 |
2 files changed, 16 insertions, 17 deletions
diff --git a/tests/specials.nim b/tests/specials.nim index a8473e34f..247f5d770 100644 --- a/tests/specials.nim +++ b/tests/specials.nim @@ -117,7 +117,7 @@ proc runThreadTests(r: var TResults, options: string) = runSingleTest(r, "tests/threads" / filename, options & " -tlsEmulation:on") test "tactors" - #test "threadex" + test "threadex" #test "threadring" #test "tthreadanalysis" #test "tthreadsort" diff --git a/tests/threads/threadex.nim b/tests/threads/threadex.nim index 5b8055413..967789ba6 100755 --- a/tests/threads/threadex.nim +++ b/tests/threads/threadex.nim @@ -1,5 +1,5 @@ discard """ - output: "" + outputsub: "All rights reserved." """ type @@ -7,39 +7,38 @@ type mLine, mEof TMsg = object {.pure, final.} case k: TMsgKind - of mEof: backTo: TThreadId[int] + of mEof: nil of mLine: data: string var - consumer: TThread[TMsg] + producer, consumer: TThread[void] + chan: TChannel[TMsg] printedLines = 0 proc consume() {.thread.} = while true: - var x = recv[TMsg]() - if x.k == mEof: - x.backTo.send(printedLines) - break + var x = recv(chan) + if x.k == mEof: break echo x.data atomicInc(printedLines) -proc produce() = +proc produce() {.thread.} = var m: TMsg var input = open("readme.txt") while not endOfFile(input): - if consumer.ready: + if chan.ready: m.data = input.readLine() - consumer.send(m) + chan.send(m) close(input) m.k = mEof - m.backTo = mainThreadId[int]() - consumer.send(m) - var result = recv[int]() - echo result + chan.send(m) -createThread(consumer, consume) -produce() +open(chan) +createThread[void](consumer, consume) +createThread[void](producer, produce) joinThread(consumer) +joinThread(producer) +close(chan) echo printedLines |