How panjf2000/ants works
ants is a Go goroutine-pool library. Callers configure a pool, submit tasks or arguments, and receive bounded concurrent execution; the library also supports capacity tuning, worker reclamation, panic handling, shutdown, and reboot. Multiple-pool variants add task distribution across pools. The graph preserves the documented capabilities and sampled worker/queue internals. Several source files were not excerpted, so links involving those components are limited to README evidence or marked unverified.
Main entry points: ants.go Pool lifecycle · pool.go Pool API · worker_queue.go Worker queue · pool_func.go Function API
Components 17
Pool APIs
- Pool API
pool.go - Function API
pool_func.go - Generic API
pool_func_generic.go - Pool options
options.go
Pool Runtime
- Pool lifecycle
ants.go
Workers And Queues
- Task worker
worker.go - Function worker
worker_func.go - Generic worker
worker_func_generic.go - Worker queue
worker_queue.go - Stack queue
worker_stack.go - Ring queue
worker_loop_queue.go
Multi-Pool And Sync
- Task multipool
multipool.go - Function multipool
multipool_func.go - Generic multipool
multipool_func_generic.go - Spin lock
pkg/sync/spinlock.go - Sync package
pkg/sync/sync.go
Other components
- Go caller
Connections 21
- Go caller → Pool API: creates pool
README.md - Go caller → Pool API: submits tasks
README.md - Go caller → Function API: submits arguments
README.md - Go caller → Pool options: configures pool
README.md - Go caller → Pool API: tunes capacity
README.md - Go caller → Pool API: releases or reboots
README.md - Pool API → Pool lifecycle: uses lifecycle
- Function API → Pool lifecycle: uses lifecycle
- Generic API → Pool lifecycle: uses lifecycle
- Pool lifecycle → Worker queue: manages workers
- Worker queue → Stack queue: selects stack
worker_queue.go - Worker queue → Ring queue: selects ring
worker_queue.go - Stack queue → Task worker: finishes workers
worker_stack.go - Ring queue → Task worker: finishes workers
worker_loop_queue.go - Task worker → Pool lifecycle: updates runtime
worker.go - Function worker → Pool lifecycle: updates runtime
worker_func.go - Generic worker → Pool lifecycle: updates runtime
worker_func_generic.go - Task multipool → Pool API: dispatches tasks
multipool.go - Function multipool → Function API: dispatches arguments
multipool_func.go - Generic multipool → Generic API: dispatches arguments
- Pool lifecycle → Spin lock: uses synchronization