Struct pconvert_rust::parallelism::ThreadPool[][src]

pub struct ThreadPool { /* fields omitted */ }
Expand description

Thread pool used in multi-threaded pconvert calls.

Implementations

Creates a thread pool with size worker threads.

Begin execution of worker threads.

Enqueues a task for execution by any of the worker threads.

Arguments

  • func - The task to execute.

Return

Returns the receiver end of a channel where the result will be placed.

Examples

use pconvert_rust::parallelism::{ResultMessage, ThreadPool};
use pconvert_rust::utils::read_png_from_file;

let mut thread_pool = ThreadPool::new(10).unwrap();
let path = "path/to/file.png".to_owned();
let demultiply = false;
let result_channel = thread_pool.execute(move || ResultMessage::ImageResult(read_png_from_file(path, demultiply)));
let top = match result_channel.recv().unwrap() {
    ResultMessage::ImageResult(result) => result,
}.unwrap();

Expands the thread pool to num_threads. Creates n workers, where n = num_threads - thread_pool_size.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.