tcallbacks.nim 345 B

123456789101112131415161718192021
  1. discard """
  2. exitcode: 0
  3. output: '''3
  4. 2
  5. 1
  6. 5
  7. '''
  8. """
  9. import asyncfutures
  10. let f1: Future[int] = newFuture[int]()
  11. f1.addCallback(proc() = echo 1)
  12. f1.addCallback(proc() = echo 2)
  13. f1.addCallback(proc() = echo 3)
  14. f1.complete(10)
  15. let f2: Future[int] = newFuture[int]()
  16. f2.addCallback(proc() = echo 4)
  17. f2.callback = proc() = echo 5
  18. f2.complete(10)