diff options
author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-06-21 00:00:00 +0000 |
---|---|---|
committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 14:59:19 +0500 |
commit | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (patch) | |
tree | fe5e17420300b715021a76328444088d32047963 /C/MtCoder.h | |
parent | 93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (diff) | |
download | 7zip-23.01.tar.gz 7zip-23.01.tar.bz2 7zip-23.01.zip |
23.0123.01
Diffstat (limited to 'C/MtCoder.h')
-rw-r--r-- | C/MtCoder.h | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/C/MtCoder.h b/C/MtCoder.h index 5a5f4d1..1231d3c 100644 --- a/C/MtCoder.h +++ b/C/MtCoder.h | |||
@@ -1,30 +1,30 @@ | |||
1 | /* MtCoder.h -- Multi-thread Coder | 1 | /* MtCoder.h -- Multi-thread Coder |
2 | 2018-07-04 : Igor Pavlov : Public domain */ | 2 | 2023-04-13 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #ifndef __MT_CODER_H | 4 | #ifndef ZIP7_INC_MT_CODER_H |
5 | #define __MT_CODER_H | 5 | #define ZIP7_INC_MT_CODER_H |
6 | 6 | ||
7 | #include "MtDec.h" | 7 | #include "MtDec.h" |
8 | 8 | ||
9 | EXTERN_C_BEGIN | 9 | EXTERN_C_BEGIN |
10 | 10 | ||
11 | /* | 11 | /* |
12 | if ( defined MTCODER__USE_WRITE_THREAD) : main thread writes all data blocks to output stream | 12 | if ( defined MTCODER_USE_WRITE_THREAD) : main thread writes all data blocks to output stream |
13 | if (not defined MTCODER__USE_WRITE_THREAD) : any coder thread can write data blocks to output stream | 13 | if (not defined MTCODER_USE_WRITE_THREAD) : any coder thread can write data blocks to output stream |
14 | */ | 14 | */ |
15 | /* #define MTCODER__USE_WRITE_THREAD */ | 15 | /* #define MTCODER_USE_WRITE_THREAD */ |
16 | 16 | ||
17 | #ifndef _7ZIP_ST | 17 | #ifndef Z7_ST |
18 | #define MTCODER__GET_NUM_BLOCKS_FROM_THREADS(numThreads) ((numThreads) + (numThreads) / 8 + 1) | 18 | #define MTCODER_GET_NUM_BLOCKS_FROM_THREADS(numThreads) ((numThreads) + (numThreads) / 8 + 1) |
19 | #define MTCODER__THREADS_MAX 64 | 19 | #define MTCODER_THREADS_MAX 64 |
20 | #define MTCODER__BLOCKS_MAX (MTCODER__GET_NUM_BLOCKS_FROM_THREADS(MTCODER__THREADS_MAX) + 3) | 20 | #define MTCODER_BLOCKS_MAX (MTCODER_GET_NUM_BLOCKS_FROM_THREADS(MTCODER_THREADS_MAX) + 3) |
21 | #else | 21 | #else |
22 | #define MTCODER__THREADS_MAX 1 | 22 | #define MTCODER_THREADS_MAX 1 |
23 | #define MTCODER__BLOCKS_MAX 1 | 23 | #define MTCODER_BLOCKS_MAX 1 |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | 26 | ||
27 | #ifndef _7ZIP_ST | 27 | #ifndef Z7_ST |
28 | 28 | ||
29 | 29 | ||
30 | typedef struct | 30 | typedef struct |
@@ -37,15 +37,15 @@ typedef struct | |||
37 | 37 | ||
38 | void MtProgressThunk_CreateVTable(CMtProgressThunk *p); | 38 | void MtProgressThunk_CreateVTable(CMtProgressThunk *p); |
39 | 39 | ||
40 | #define MtProgressThunk_Init(p) { (p)->inSize = 0; (p)->outSize = 0; } | 40 | #define MtProgressThunk_INIT(p) { (p)->inSize = 0; (p)->outSize = 0; } |
41 | 41 | ||
42 | 42 | ||
43 | struct _CMtCoder; | 43 | struct CMtCoder_; |
44 | 44 | ||
45 | 45 | ||
46 | typedef struct | 46 | typedef struct |
47 | { | 47 | { |
48 | struct _CMtCoder *mtCoder; | 48 | struct CMtCoder_ *mtCoder; |
49 | unsigned index; | 49 | unsigned index; |
50 | int stop; | 50 | int stop; |
51 | Byte *inBuf; | 51 | Byte *inBuf; |
@@ -71,7 +71,7 @@ typedef struct | |||
71 | } CMtCoderBlock; | 71 | } CMtCoderBlock; |
72 | 72 | ||
73 | 73 | ||
74 | typedef struct _CMtCoder | 74 | typedef struct CMtCoder_ |
75 | { | 75 | { |
76 | /* input variables */ | 76 | /* input variables */ |
77 | 77 | ||
@@ -79,11 +79,11 @@ typedef struct _CMtCoder | |||
79 | unsigned numThreadsMax; | 79 | unsigned numThreadsMax; |
80 | UInt64 expectedDataSize; | 80 | UInt64 expectedDataSize; |
81 | 81 | ||
82 | ISeqInStream *inStream; | 82 | ISeqInStreamPtr inStream; |
83 | const Byte *inData; | 83 | const Byte *inData; |
84 | size_t inDataSize; | 84 | size_t inDataSize; |
85 | 85 | ||
86 | ICompressProgress *progress; | 86 | ICompressProgressPtr progress; |
87 | ISzAllocPtr allocBig; | 87 | ISzAllocPtr allocBig; |
88 | 88 | ||
89 | IMtCoderCallback2 *mtCallback; | 89 | IMtCoderCallback2 *mtCallback; |
@@ -100,13 +100,13 @@ typedef struct _CMtCoder | |||
100 | BoolInt stopReading; | 100 | BoolInt stopReading; |
101 | SRes readRes; | 101 | SRes readRes; |
102 | 102 | ||
103 | #ifdef MTCODER__USE_WRITE_THREAD | 103 | #ifdef MTCODER_USE_WRITE_THREAD |
104 | CAutoResetEvent writeEvents[MTCODER__BLOCKS_MAX]; | 104 | CAutoResetEvent writeEvents[MTCODER_BLOCKS_MAX]; |
105 | #else | 105 | #else |
106 | CAutoResetEvent finishedEvent; | 106 | CAutoResetEvent finishedEvent; |
107 | SRes writeRes; | 107 | SRes writeRes; |
108 | unsigned writeIndex; | 108 | unsigned writeIndex; |
109 | Byte ReadyBlocks[MTCODER__BLOCKS_MAX]; | 109 | Byte ReadyBlocks[MTCODER_BLOCKS_MAX]; |
110 | LONG numFinishedThreads; | 110 | LONG numFinishedThreads; |
111 | #endif | 111 | #endif |
112 | 112 | ||
@@ -120,11 +120,11 @@ typedef struct _CMtCoder | |||
120 | CCriticalSection cs; | 120 | CCriticalSection cs; |
121 | 121 | ||
122 | unsigned freeBlockHead; | 122 | unsigned freeBlockHead; |
123 | unsigned freeBlockList[MTCODER__BLOCKS_MAX]; | 123 | unsigned freeBlockList[MTCODER_BLOCKS_MAX]; |
124 | 124 | ||
125 | CMtProgress mtProgress; | 125 | CMtProgress mtProgress; |
126 | CMtCoderBlock blocks[MTCODER__BLOCKS_MAX]; | 126 | CMtCoderBlock blocks[MTCODER_BLOCKS_MAX]; |
127 | CMtCoderThread threads[MTCODER__THREADS_MAX]; | 127 | CMtCoderThread threads[MTCODER_THREADS_MAX]; |
128 | } CMtCoder; | 128 | } CMtCoder; |
129 | 129 | ||
130 | 130 | ||