tflowvar.nim 551 B

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