tflowvar.nim 529 B

12345678910111213141516171819202122232425262728293031323334353637
  1. discard """
  2. output: '''foobarfoobar
  3. bazbearbazbear
  4. 1'''
  5. cmd: "nim $target --threads:on $options $file"
  6. """
  7. import threadpool
  8. proc computeSomething(a, b: string): string = a & b & a & b & "\n"
  9. proc main =
  10. let fvA = spawn computeSomething("foo", "bar")
  11. let fvB = spawn computeSomething("baz", "bear")
  12. echo(^fvA, ^fvB)
  13. main()
  14. sync()
  15. type
  16. TIntSeq = seq[int]
  17. proc t(): TIntSeq =
  18. result = @[1]
  19. proc p(): int =
  20. var a: FlowVar[TIntSeq]
  21. parallel:
  22. var aa = spawn t()
  23. a = aa
  24. result = (^a)[0]
  25. echo p()