Module autocompress::iothread [−][src]
Expand description
Run compression, decompression and other IO tasks in separated threads.
Please read IoThread
to learn more.
Example:
use autocompress::{iothread::IoThread, open, create, CompressionLevel}; use std::io::{prelude::*, self}; let nothread_reader = open("testfiles/plain.txt")?; let nothread_writer = create("target/plain.txt.xz", CompressionLevel::Default)?; let thread_pool = IoThread::new(2); let mut threaded_reader = thread_pool.add_reader(nothread_reader)?; let mut threaded_writer = thread_pool.add_writer(nothread_writer); let mut buffer = Vec::new(); threaded_reader.read_to_end(&mut buffer)?; assert_eq!(buffer, b"ABCDEFG\r\n1234567"); threaded_writer.write_all(b"ABCDEFG\r\n1234567")?;
Structs
Methods for threaded compression
Threaded writer. Creates with super::IoThread::add_block_writer
.
Thread pool for I/O tasks
Threaded reader. Creates with IoThread::add_reader
.
Threaded writer. Creates with IoThread::add_writer
.