Struct rpm_timer::RpmTimer [] [src]

pub struct RpmTimer { /* fields omitted */ }

Use this struct to limit the speed of any items processing.

Adjust processing speed using struct's methods.

Example usage:

extern crate rpm_timer;

use rpm_timer::RpmTimer;

fn main() {
    let items = &["Hello", "World!", "How", "are", "you?"];

    RpmTimer::default()
        .rps_limit(1.0)
        .max_threads(1)
        .run_slice(items, print);
}

fn print(items: &[&str]) {
    for item in items {
        println!("{}", item);
    }
}

Methods

impl RpmTimer
[src]

[src]

Main thread will try to spawn working threads every tick.

Tip: yhe higher RPM requested, the lower tick duration should be.

Default: 100 ms

[src]

Target requests per minute number. It overrides the value previously set by rps_limit, if any.

Default: 60

[src]

Target requests per second number. It overrides the value previously set by rpm_limit, if any.

Default: 1

[src]

Maximum number of working threads in the pool.

Pass None to limit the number to the number of cpu cores (uses num_cpus under the hood).

Default: None

[src]

Non-allocating method that spawns thread and pass sub-slices to the workers.

This is the preffered way unless you only have an iterator.

It waits for all spawned threads to finish.

[src]

Allocating method that spawns thread and pass vectors with collected items to the workers.

This is the most generic solution but you should only use it when run_slice is not possible..

It waits for all spawned threads to finish.

Trait Implementations

impl Default for RpmTimer
[src]

[src]

Returns the "default value" for a type. Read more