Struct exr::block::writer::ParallelBlocksCompressor
source · pub struct ParallelBlocksCompressor<'w, W> {
meta: &'w MetaData,
sorted_writer: SortedBlocksWriter<'w, W>,
sender: Sender<Result<(usize, usize, Chunk)>>,
receiver: Receiver<Result<(usize, usize, Chunk)>>,
pool: ThreadPool,
currently_compressing_count: usize,
written_chunk_count: usize,
max_threads: usize,
next_incoming_chunk_index: usize,
}
Expand description
Compress blocks to a chunk writer with multiple threads.
Fields§
§meta: &'w MetaData
§sorted_writer: SortedBlocksWriter<'w, W>
§sender: Sender<Result<(usize, usize, Chunk)>>
§receiver: Receiver<Result<(usize, usize, Chunk)>>
§pool: ThreadPool
§currently_compressing_count: usize
§written_chunk_count: usize
§max_threads: usize
§next_incoming_chunk_index: usize
Implementations§
source§impl<'w, W> ParallelBlocksCompressor<'w, W>where
W: 'w + ChunksWriter,
impl<'w, W> ParallelBlocksCompressor<'w, W>where
W: 'w + ChunksWriter,
sourcepub fn new(meta: &'w MetaData, chunks_writer: &'w mut W) -> Option<Self>
pub fn new(meta: &'w MetaData, chunks_writer: &'w mut W) -> Option<Self>
New blocks writer. Returns none if sequential compression should be used.
Use new_with_thread_pool
to customize the threadpool.
sourcepub fn new_with_thread_pool<CreatePool>(
meta: &'w MetaData,
chunks_writer: &'w mut W,
try_create_thread_pool: CreatePool,
) -> Option<Self>
pub fn new_with_thread_pool<CreatePool>( meta: &'w MetaData, chunks_writer: &'w mut W, try_create_thread_pool: CreatePool, ) -> Option<Self>
New blocks writer. Returns none if sequential compression should be used.
sourcepub fn inner_chunks_writer(&'w self) -> &'w W
pub fn inner_chunks_writer(&'w self) -> &'w W
This is where the compressed blocks are written to.
fn write_next_queued_chunk(&mut self) -> UnitResult
sourcepub fn write_all_queued_chunks(&mut self) -> UnitResult
pub fn write_all_queued_chunks(&mut self) -> UnitResult
Wait until all currently compressing chunks in the compressor have been written.
sourcepub fn add_block_to_compression_queue(
&mut self,
index_in_header_increasing_y: usize,
block: UncompressedBlock,
) -> UnitResult
pub fn add_block_to_compression_queue( &mut self, index_in_header_increasing_y: usize, block: UncompressedBlock, ) -> UnitResult
Add a single block to the compressor queue. The index of the block must be in increasing line order.
When calling this function for the last block, this method waits until all the blocks have been written.
This only works when you write as many blocks as the image expects, otherwise you can use wait_for_all_remaining_chunks
.
Waits for a block from the queue to be written, if the queue already has enough items.