vec_parallel
A library for building vectors in parallel using async tasks.
This crate provides utilities to construct Vec<T>
in parallel by dividing the work into
multiple async tasks that can run concurrently. This is particularly useful for CPU-bound
initialization tasks where elements can be computed independently.
Example
use ;
// Build a vector of squares using multiple tasks
let builder = build_vec;
// Run the tasks (in a real application, these would be spawned on an executor)
for task in builder.tasks
// Get the final result
let squares = spin_on;
assert_eq!; // 10² = 100
Features
- Flexible parallelization strategies: Choose how many tasks to create
- Zero-copy construction: Elements are written directly to their final location
- Executor-agnostic: Works with any async runtime
- Optional executor integration: Use the
some_executor
feature for convenient spawning