testmanyasyncevents.nim 503 B

12345678910111213141516171819202122232425
  1. discard """
  2. output: '''
  3. hasPendingOperations: false
  4. triggerCount: 100
  5. '''
  6. disabled: "windows"
  7. """
  8. import asyncDispatch
  9. var triggerCount = 0
  10. var evs = newSeq[AsyncEvent]()
  11. for i in 0 ..< 100: # has to be lower than the typical physical fd limit
  12. var ev = newAsyncEvent()
  13. evs.add(ev)
  14. addEvent(ev, proc(fd: AsyncFD): bool {.gcsafe,closure.} = triggerCount += 1; true)
  15. for ev in evs:
  16. ev.trigger()
  17. drain()
  18. echo "hasPendingOperations: ", hasPendingOperations()
  19. echo "triggerCount: ", triggerCount