pub fn add_block_to_compression_queue(&mut self, index_in_header_increasing_y: usize, block: UncompressedBlock) -> UnitResult {

        // if pipe is full, block to wait for a slot to free up
        if self.currently_compressing_count >= self.max_threads {
            self.write_next_queued_chunk()?;
        }

        // add the argument chunk to the compression queueue
        let index_in_file = self.next_incoming_chunk_index;
        let sender = self.sender.clone();
        let meta = self.meta.clone();

        self.pool.execute(move ||{
            let compressed_or_err = block.compress_to_chunk(&meta.headers);

            // by now, decompressing could have failed in another thread.
            // the error is then already handled, so we simply
            // don't send the decompressed block and do nothing
            let _ = sender.send(compressed_or_err.map(move |compressed| (index_in_file, index_in_header_increasing_y, compressed)));
        });

        self.currently_compressing_count += 1;
        self.next_incoming_chunk_index += 1;

        // if this is the last chunk, wait for all chunks to complete before returning
        if self.written_chunk_count + self.currently_compressing_count == self.inner_chunks_writer().total_chunks_count() {
            self.write_all_queued_chunks()?;
            debug_assert_eq!(
                self.written_chunk_count, self.inner_chunks_writer().total_chunks_count(),
                "written chunk count mismatch"
            );
        }


        Ok(())
    }
/// 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.
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.
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 .
pub fn add_block_to_compression_queue(&mut self, index_in_header_increasing_y: usize, block: UncompressedBlock) -> UnitResult {
        // if pipe is full, block to wait for a slot to free up
        if self.currently_compressing_count >= self.max_threads {
            self.write_next_queued_chunk()?;
        }
        // add the argument chunk to the compression queueue
        let index_in_file = self.next_incoming_chunk_index;
        let sender = self.sender.clone();
        let meta = self.meta.clone();
        self.pool.execute(move ||{
            let compressed_or_err = block.compress_to_chunk(&meta.headers);
            // by now, decompressing could have failed in another thread.
            // the error is then already handled, so we simply
            // don't send the decompressed block and do nothing
            let _ = sender.send(compressed_or_err.map(move |compressed| (index_in_file, index_in_header_increasing_y, compressed)));
        });
        self.currently_compressing_count += 1;
        self.next_incoming_chunk_index += 1;
        // if this is the last chunk, wait for all chunks to complete before returning
        if self.written_chunk_count + self.currently_compressing_count == self.inner_chunks_writer().total_chunks_count() {
            self.write_all_queued_chunks()?;
            debug_assert_eq!(
                self.written_chunk_count, self.inner_chunks_writer().total_chunks_count(),
                "written chunk count mismatch"
            );
        }
        Ok(())
    }
pub fn add_block_to_compression_queue ( & mut self , index_in_header_increasing_y : usize , block : UncompressedBlock ) -> UnitResult { // if pipe is full, block to wait for a slot to free up if self . currently_compressing_count >= self . max_threads { self . write_next_queued_chunk ( ) ? ; } // add the argument chunk to the compression queueue let index_in_file = self . next_incoming_chunk_index ; let sender = self . sender . clone ( ) ; let meta = self . meta . clone ( ) ; self . pool . execute ( move | | { let compressed_or_err = block . compress_to_chunk ( & meta . headers ) ; // by now, decompressing could have failed in another thread. // the error is then already handled, so we simply // don't send the decompressed block and do nothing let _ = sender . send ( compressed_or_err . map ( move | compressed | ( index_in_file , index_in_header_increasing_y , compressed ) ) ) ; } ) ; self . currently_compressing_count += 1 ; self . next_incoming_chunk_index += 1 ; // if this is the last chunk, wait for all chunks to complete before returning if self . written_chunk_count + self . currently_compressing_count == self . inner_chunks_writer ( ) . total_chunks_count ( ) { self . write_all_queued_chunks ( ) ? ; debug_assert_eq ! ( self written_chunk_count self inner_chunks_writer ( ) total_chunks_count ( ) " " ) ; } Ok ( ( ) ) }
Add a single block to the compressor queue.
Add a single block to the compressor queue .
&mut self
index_in_header_increasing_y
usize
block
UncompressedBlock
&mut self
index_in_header_increasing_y
usize
block
UncompressedBlock