Expand description
Object pooling for geometry types to reduce allocations
This module provides thread-local object pools for frequently allocated geometry types (Point, LineString, Polygon). Object pooling can significantly reduce allocation overhead in batch spatial operations.
§Performance Benefits
When performing many spatial operations in sequence, object pooling can:
- Reduce allocations by 2-3x for batch operations
- Decrease GC pressure and memory fragmentation
- Improve cache locality for frequently reused objects
§Thread Safety
All pools are thread-local, eliminating synchronization overhead. Each thread maintains its own independent pools.
§Usage Example
use oxigdal_algorithms::vector::{Point, buffer_point_pooled, BufferOptions};
let point = Point::new(0.0, 0.0);
let options = BufferOptions::default();
// Get a pooled polygon - automatically returned to pool when guard drops
let buffered = buffer_point_pooled(&point, 10.0, &options)?;
// Use the buffered geometry...
// Automatically returned to pool hereStructs§
- Pool
- Generic object pool for reusable objects
- Pool
Guard - RAII guard that returns an object to the pool when dropped
- Pool
Stats - Gets statistics about pool usage for the current thread
Functions§
- clear_
all_ pools - Clears all thread-local pools
- get_
pool_ stats - Returns statistics about current pool usage
- get_
pooled_ coordinate_ vec - Gets a
Vec<Coordinate>from the thread-local pool - get_
pooled_ linestring - Gets a LineString from the thread-local pool
- get_
pooled_ point - Gets a Point from the thread-local pool
- get_
pooled_ polygon - Gets a Polygon from the thread-local pool