Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/haraldh/dynqueue

dynamically extendable Rayon parallel iterator
https://github.com/haraldh/dynqueue

Last synced: 4 months ago
JSON representation

dynamically extendable Rayon parallel iterator

Awesome Lists containing this project

README

        

[![Rust](https://github.com/haraldh/dynqueue/workflows/Rust/badge.svg)](https://github.com/haraldh/dynqueue/actions)
[![Coverage Status](https://coveralls.io/repos/github/haraldh/dynqueue/badge.svg?branch=master)](https://coveralls.io/github/haraldh/dynqueue?branch=master)

# DynQueue - dynamically extendable Rayon parallel iterator

A `DynQueue` can be iterated with `into_par_iter` producing `(DynQueueHandle, T)` elements.
With the `DynQueueHandle` a new `T` can be inserted in the `DynQueue`,
which is currently iterated over.

A `Vec`, `VecDeque` and `crossbeam_queue::SegQueue` (with `feature = "crossbeam-queue"`)
can be turned into a `DynQueue` with `.into_dyn_queue()`.

```rust
use rayon::iter::IntoParallelIterator as _;
use rayon::iter::ParallelIterator as _;

use dynqueue::IntoDynQueue as _;

fn main() {
let mut result = vec![1, 2, 3]
.into_dyn_queue()
.into_par_iter()
.map(|(handle, value)| { if value == 2 { handle.enqueue(4) }; value })
.collect::>();
result.sort();

assert_eq!(result, vec![1, 2, 3, 4]);
}
```

## Features

* `crossbeam-queue` : to use `crossbeam::queue::SegQueue` as the inner collection.

## Changelog

### 0.2.0
- introduce `IntoDynQueue`
- handle lockless collections

### 0.1.0
- initial version