コード例 #1
0
ファイル: Cover.cs プロジェクト: oleg-st/ZstdSharp
        /**
         * Called when a thread is about to be launched.
         * Increments liveJobs.
         */
        public static void COVER_best_start(COVER_best_s *best)
        {
            if (best == null)
            {
                return;
            }


            ++best->liveJobs;
        }
コード例 #2
0
ファイル: Cover.cs プロジェクト: oleg-st/ZstdSharp
        /**
         * Wait until liveJobs == 0.
         */
        public static void COVER_best_wait(COVER_best_s *best)
        {
            if (best == null)
            {
                return;
            }


            while (best->liveJobs != 0)
            {
            }
        }
コード例 #3
0
ファイル: Cover.cs プロジェクト: oleg-st/ZstdSharp
        /**
         * Called when a thread finishes executing, both on error or success.
         * Decrements liveJobs and signals any waiting threads if liveJobs == 0.
         * If this dictionary is the best so far save it and its parameters.
         */
        public static void COVER_best_finish(COVER_best_s *best, ZDICT_cover_params_t parameters, COVER_dictSelection selection)
        {
            void *dict           = (void *)selection.dictContent;
            nuint compressedSize = selection.totalCompressedSize;
            nuint dictSize       = selection.dictSize;

            if (best == null)
            {
                return;
            }


            {
                nuint liveJobs;


                --best->liveJobs;
                liveJobs = best->liveJobs;
                if (compressedSize < best->compressedSize)
                {
                    if (best->dict == null || best->dictSize < dictSize)
                    {
                        if (best->dict != null)
                        {
                            free(best->dict);
                        }

                        best->dict = malloc(dictSize);
                        if (best->dict == null)
                        {
                            best->compressedSize = (unchecked ((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_GENERIC)));
                            best->dictSize       = 0;


                            return;
                        }
                    }

                    if (dict != null)
                    {
                        memcpy(best->dict, dict, dictSize);
                        best->dictSize       = dictSize;
                        best->parameters     = parameters;
                        best->compressedSize = compressedSize;
                    }
                }

                if (liveJobs == 0)
                {
                }
            }
        }
コード例 #4
0
ファイル: Cover.cs プロジェクト: oleg-st/ZstdSharp
        /**
         * Call COVER_best_wait() and then destroy the COVER_best_t.
         */
        public static void COVER_best_destroy(COVER_best_s *best)
        {
            if (best == null)
            {
                return;
            }

            COVER_best_wait(best);
            if (best->dict != null)
            {
                free(best->dict);
            }
        }
コード例 #5
0
ファイル: Cover.cs プロジェクト: oleg-st/ZstdSharp
        /**
         * Initialize the `COVER_best_t`.
         */
        public static void COVER_best_init(COVER_best_s *best)
        {
            if (best == null)
            {
                return;
            }



            best->liveJobs       = 0;
            best->dict           = null;
            best->dictSize       = 0;
            best->compressedSize = unchecked ((nuint)(-1));
            memset((void *)&best->parameters, 0, (nuint)(sizeof(ZDICT_cover_params_t)));
        }