pub fn new(meta: &'w MetaData, chunks_writer: &'w mut W, pool: threadpool::ThreadPool) -> Option<Self> {
        if meta.headers.iter().all(|head|head.compression == Compression::Uncompressed) {
            return None;
        }

        let max_threads = pool.max_count().max(1).min(chunks_writer.total_chunks_count()) + 2; // ca one block for each thread at all times
        let (send, recv) = flume::unbounded(); // TODO bounded channel simplifies logic?

        Some(Self {
            sorted_writer: SortedBlocksWriter::new(meta, chunks_writer),
            next_incoming_chunk_index: 0,
            currently_compressing_count: 0,
            written_chunk_count: 0,
            sender: send,
            receiver: recv,
            max_threads,
            pool,
            meta,
        })
    }
/// New blocks writer. Returns none if sequential compression should be used.
New blocks writer. Returns none if sequential compression should be used.
New blocks writer . Returns none if sequential compression should be used .
pub fn new(meta: &'w MetaData, chunks_writer: &'w mut W, pool: threadpool::ThreadPool) -> Option<Self> {
        if meta.headers.iter().all(|head|head.compression == Compression::Uncompressed) {
            return None;
        }
        let max_threads = pool.max_count().max(1).min(chunks_writer.total_chunks_count()) + 2; // ca one block for each thread at all times
        let (send, recv) = flume::unbounded(); // TODO bounded channel simplifies logic?
        Some(Self {
            sorted_writer: SortedBlocksWriter::new(meta, chunks_writer),
            next_incoming_chunk_index: 0,
            currently_compressing_count: 0,
            written_chunk_count: 0,
            sender: send,
            receiver: recv,
            max_threads,
            pool,
            meta,
        })
    }
pub fn new ( meta : & ' w MetaData , chunks_writer : & ' w mut W , pool : threadpool :: ThreadPool ) -> Option < Self > { if meta . headers . iter ( ) . all ( | head | head . compression == Compression :: Uncompressed ) { return None ; } let max_threads = pool . max_count ( ) . max ( 1 ) . min ( chunks_writer . total_chunks_count ( ) ) + 2 ; // ca one block for each thread at all times let ( send , recv ) = flume :: unbounded ( ) ; // TODO bounded channel simplifies logic? Some ( Self { sorted_writer : SortedBlocksWriter :: new ( meta , chunks_writer ) , next_incoming_chunk_index : 0 , currently_compressing_count : 0 , written_chunk_count : 0 , sender : send , receiver : recv , max_threads , pool , meta , } ) }
New blocks writer.
New blocks writer .
meta
&'w MetaData
chunks_writer
&'w mut W
pool
threadpool::ThreadPool
meta
&'w MetaData
chunks_writer
&'w mut W
pool
threadpool::ThreadPool