Skip to content

Performs tasks in parallel returning completed tasks in order of appearance from source iterator.

License

Unlicense and 2 other licenses found

Licenses found

Unlicense
UNLICENSE
Unknown
COPYING
MIT
MIT-LICENSE
Notifications You must be signed in to change notification settings

kilork/ordered-parallel-iterator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ordered-parallel-iterator

This crate provides an iterator over task results which performs tasks in parallel returning completed tasks in order of source range iterator. It can be useful if you need to process some data in parallel but need to have results in the order of appearance (FIFO).

Legal

Dual-licensed under MIT or the UNLICENSE.

Installation

Add following dependency to your Cargo.toml:

[dependencies]
ordered-parallel-iterator = "0.2"

Usage

use ordered_parallel_iterator::OrderedParallelIterator;

fn run_me(x: usize) -> usize {
    x + 1
}

fn main() {
    for i in OrderedParallelIterator::new(|| 0..10, || run_me) {
        println!("Result from iterator: {}", i);
    }
}

In this example each run_me call will happen in own thread, but results will be returned sequentially as fast as first will be finished. Count of pending tasks running in parallel bind to count of CPU cores.

About

Performs tasks in parallel returning completed tasks in order of appearance from source iterator.

Resources

License

Unlicense and 2 other licenses found

Licenses found

Unlicense
UNLICENSE
Unknown
COPYING
MIT
MIT-LICENSE

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages