summary refs log tree commit diff stats
path: root/tests/parallel/tlet_spawn.nim
blob: 853ffc44323e2cf86acee402e5171b6b56d069e5 (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
discard """
output: '''
done999 999
'''
"""

import std/[threadpool, os]

proc foo(): int = 999

# test that the disjoint checker deals with 'a = spawn f(); g = spawn f()':

proc main =
  parallel:
    let f = spawn foo()
    let b = spawn foo()
  echo "done", f, " ", b

main()

# bug #13781
proc thread(): string =
  os.sleep(1000)
  return "ok"

var fv = spawn thread()
sync()
doAssert ^fv == "ok"