Struct autocompress::iothread::IoThread[][src]

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

Thread pool for I/O tasks

Implementations

Create new I/O thread pool

Open file with multi threaded reader.

Example:

use autocompress::iothread::IoThread;
let iothread = IoThread::new(2);
let mut reader = iothread.open("testfiles/plain.txt.gz")?;
let mut buffer = Vec::new();
reader.read_to_end(&mut buffer)?;
assert_eq!(buffer, b"ABCDEFG\r\n1234567");

Creates file with multi threaded writer.

Example:

use autocompress::{iothread::IoThread, CompressionLevel};
let iothread = IoThread::new(2);
let mut writer = iothread.create("target/block-writer1.txt.gz", CompressionLevel::Default)?;
writer.write_all(b"ABCDEFG")?;

Creates new multi threaded compressor. This writer has buffers, so wrapping with std::io::BufWriter is not required.

Example:

use autocompress::iothread::{IoThread, BlockCompress};
use autocompress::CompressionLevel;
let mut gzip_block_compress = BlockCompress::gzip(CompressionLevel::Default);
let file_writer = std::fs::File::create("target/block-writer2.txt.gz")?;
let iothread = IoThread::new(1);
let mut block_writer = iothread.add_block_writer(file_writer, gzip_block_compress);
block_writer.write_all(b"ABCDEFG")?;

Register new writer and create threaded writer. Since each write requests cause inter thread communication, wrapping with std::io::BufWriter is recommended.

Example:

use autocompress::{iothread::IoThread, create, CompressionLevel};
use std::io::{prelude::*, self};

let nothread_writer = create("target/plain2.txt.xz", CompressionLevel::Default)?;
let thread_pool = IoThread::new(2);
let mut threaded_writer = thread_pool.add_writer(nothread_writer);
threaded_writer.write_all(b"ABCDEFG\r\n1234567")?;

Register new writer and create threaded reader.

Example:

use autocompress::{iothread::IoThread, open};
use std::io::{prelude::*, self};

let nothread_reader = open("testfiles/plain.txt")?;
let thread_pool = IoThread::new(2);
let mut threaded_reader = thread_pool.add_reader(nothread_reader)?;
let mut buffer = Vec::new();
threaded_reader.read_to_end(&mut buffer)?;
assert_eq!(buffer, b"ABCDEFG\r\n1234567");

Register new writer and create threaded reader with buffer capacity.

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.