Ejemplo n.º 1
0
        internal static lzma_ret CreateEncoder(lzma_stream stream, int threads, uint preset)
        {
            // adjust thread numbers
            if (threads > Environment.ProcessorCount)
            {
                Trace.TraceWarning("it's not reasonable to have more threads than processors");
                threads = Environment.ProcessorCount;
            }

            if (threads == 1)
            {
                // single thread compress
                return(Native.lzma_easy_encoder(stream, preset, lzma_check.LZMA_CHECK_CRC64));
            }
            else
            {
                // multi thread compress
                var mt = new lzma_mt
                {
                    threads = (uint)threads,
                    check   = lzma_check.LZMA_CHECK_CRC64,
                    preset  = preset,
                };
                return(Native.lzma_stream_encoder_mt(stream, mt));
            }
        }
Ejemplo n.º 2
0
        internal static lzma_ret CreateEncoder(lzma_stream stream, int threads, uint preset)
        {
            // adjust thread numbers
            if (threads > Environment.ProcessorCount)
            {
                Trace.TraceWarning("it's not reasonable to have more threads than processors");
                threads = Environment.ProcessorCount;
            }

            if (threads == 1)
            {
                // single thread compress
                return Native.lzma_easy_encoder(stream, preset, lzma_check.LZMA_CHECK_CRC64);
            }
            else
            {
                // multi thread compress
                var mt = new lzma_mt
                         {
                             threads = (uint)threads,
                             check = lzma_check.LZMA_CHECK_CRC64,
                             preset = preset,
                         };
                return Native.lzma_stream_encoder_mt(stream, mt);
            }
        }