summary refs log tree commit diff stats
path: root/tests/threads/threadex.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/threads/threadex.nim')
-rw-r--r--[-rwxr-xr-x]tests/threads/threadex.nim22
1 files changed, 14 insertions, 8 deletions
diff --git a/tests/threads/threadex.nim b/tests/threads/threadex.nim
index 0360c8c04..90119aee7 100755..100644
--- a/tests/threads/threadex.nim
+++ b/tests/threads/threadex.nim
@@ -1,21 +1,25 @@
 discard """
-  outputsub: "All rights reserved."
+  disabled: i386
+  outputsub: "Just a simple text for test"
 """
 
 type
   TMsgKind = enum
     mLine, mEof
-  TMsg = object {.pure, final.}
+  TMsg = object
     case k: TMsgKind
-    of mEof: nil
+    of mEof: discard
     of mLine: data: string
 
 var
-  producer, consumer: TThread[void]
-  chan: TChannel[TMsg]
+  producer, consumer: Thread[void]
+  chan: Channel[TMsg]
   printedLines = 0
+  prodId: int
+  consId: int
 
 proc consume() {.thread.} =
+  consId = getThreadId()
   while true:
     var x = recv(chan)
     if x.k == mEof: break
@@ -23,16 +27,17 @@ proc consume() {.thread.} =
     atomicInc(printedLines)
 
 proc produce() {.thread.} =
+  prodId = getThreadId()
   var m: TMsg
-  var input = open("readme.txt")
+  var input = open("tests/dummy.txt")
   var line = ""
   while input.readLine(line):
     m.data = line
     chan.send(m)
   close(input)
-  m.k = mEof
+  m = TMsg(k: mEof)
   chan.send(m)
-  
+
 open(chan)
 createThread[void](consumer, consume)
 createThread[void](producer, produce)
@@ -40,5 +45,6 @@ joinThread(consumer)
 joinThread(producer)
 
 close(chan)
+doAssert prodId != consId
 echo printedLines