Wait Group
Synchronize parallel operations - wait for multiple concurrent tasks to complete before proceeding.
Overview
The Wait Group package provides synchronization primitives for parallel processing. Use it when you need to run multiple operations concurrently and wait for all of them to complete before continuing.
Key Features
- Parallel Execution - Run multiple tasks concurrently
- Synchronization - Wait for all tasks to complete
- Counter Management - Track pending operations
Available Nodes
- WG Create - Create a new wait group
- WG Add - Add tasks to the wait group counter
- WG Done - Mark a task as complete
- WG Wait - Wait for all tasks to complete
When to Use This Package
- Parallel Processing: Process multiple items simultaneously
- Batch Operations: Wait for batch to complete
- Performance: Speed up workflows with concurrency
- Resource Optimization: Maximize throughput
How It Works
- Create a wait group with expected task count
- Start parallel tasks
- Each task calls Done when complete
- Main flow waits until all tasks are done
Typical Workflow
- WG Create with count of parallel tasks
- Start parallel processing branches
- WG Done in each branch when complete
- WG Wait to block until all done
- Continue with combined results
Use Cases
- Download multiple files in parallel
- Process multiple API calls concurrently
- Run parallel database queries
- Execute multiple independent operations
- Aggregate results from parallel tasks
Notes
- Ensure Done is called for each Add
- WG Wait blocks until counter reaches zero
- Use for fan-out/fan-in patterns
📄️ WG Add
Core.WaitGroup.Add
📄️ WG Create
Core.WaitGroup.Create
📄️ WG Done
Core.WaitGroup.Done
📄️ WG Wait
Core.WaitGroup.Wait