blob: 5139920ea7dd019c15c7124a8a3f2b80ac39988f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
discard """
sortoutput: true
output: '''
(x: 0.0)
(x: 0.0)
(x: 0.0)
test
test
test
'''
"""
# bug #2257
import threadpool
type StringChannel = Channel[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 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 true:
main()
|