diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-04-30 16:09:27 +0100 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-04-30 16:09:27 +0100 |
commit | 0be654efe11311fcf1200c0e7dba9ecd55fa5591 (patch) | |
tree | 7f55b6c5f467a7094fb0978841a08a9b1764f0c3 /tests/parallel/tgc_unsafe.nim | |
parent | 4e778f9aac184655135daaff6579ef4a553d225a (diff) | |
parent | d9d5aa60b7df936ffe6149143c7202604f71465f (diff) | |
download | Nim-0be654efe11311fcf1200c0e7dba9ecd55fa5591.tar.gz |
Merge branch 'devel'
Diffstat (limited to 'tests/parallel/tgc_unsafe.nim')
-rw-r--r-- | tests/parallel/tgc_unsafe.nim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/parallel/tgc_unsafe.nim b/tests/parallel/tgc_unsafe.nim new file mode 100644 index 000000000..6548bbec8 --- /dev/null +++ b/tests/parallel/tgc_unsafe.nim @@ -0,0 +1,32 @@ +discard """ + errormsg: "'consumer' is not GC-safe" + line: 19 +""" + +# bug #2257 +import threadpool + +type StringChannel = TChannel[string] +var channels: array[1..3, StringChannel] + +type + MyObject[T] = object + x: T + +var global: MyObject[string] +var globalB: MyObject[float] + +proc consumer(ix : int) {.thread.} = + echo channels[ix].recv() ###### not GC-safe: 'channels' + echo global + echo globalB + +proc main = + for ix in 1..3: channels[ix].open() + for ix in 1..3: spawn consumer(ix) + for ix in 1..3: channels[ix].send("test") + sync() + for ix in 1..3: channels[ix].close() + +when isMainModule: + main() |