panjf2000 / ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.
https://ants.andypan.me/
MIT License
12.69k stars 1.36k forks source link

[Question]: Can ants execute tasks in order? #312

Closed rts-gordon closed 8 months ago

rts-gordon commented 8 months ago

Questions with details

Hi there, Thanks for the ants awesome project, it is very powerful. The tasks in pool execute is unordered, it is possible execute tasks in order?

Thank you.

Code snippets (optional)

No response

panjf2000 commented 8 months ago

Were you talking about executing tasks in serialization? If so, I don't think any pools with concurrency purposes can and should do that. If you want to run your tasks in a strict order, why bother to use a pool? Why not just do it in one goroutine?

On the other hand, if what you wanted is the priority queue, then that's something conceivable, see #59