wait - Flow Control
Overview
The wait module provides flow control utilities including semaphore pools, synchronization, and timeout management.
Functions
Lock()
Acquire lock for specified key.
Parameters:
key- Lock identifier
Behavior:
- Blocks until lock is available
- Panics if key does not exist
Example:
Unlock()
Release lock for specified key.
Parameters:
key- Lock identifier
Behavior:
- Releases lock
- Panics if key does not exist
Example:
Depth()
Get current depth for specified key.
Parameters:
key- Lock identifier
Returns:
- Current depth (number of acquired locks)
Example:
Sync()
Execute logic function with lock.
Parameters:
key- Lock identifierlogic- Function to execute
Returns:
- Error from logic function
Example:
Ready()
Initialize semaphore for specified key.
Parameters:
key- Lock identifiermax- Maximum concurrency
Example:
Usage Patterns
Rate Limiting
Resource Pooling
Critical Sections
Concurrency Control
Best Practices
Lock Management
Initialization
Related Documentation
- routine - Goroutine management
- hystrix - Circuit breaker
- API Documentation
- Module Overview