Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
MtCoder.h
Go to the documentation of this file.
1/* MtCoder.h -- Multi-thread Coder
22023-04-13 : Igor Pavlov : Public domain */
3
4#ifndef ZIP7_INC_MT_CODER_H
5#define ZIP7_INC_MT_CODER_H
6
7#include "MtDec.h"
8
10
11/*
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
14*/
15/* #define MTCODER_USE_WRITE_THREAD */
16
17#ifndef Z7_ST
18 #define MTCODER_GET_NUM_BLOCKS_FROM_THREADS(numThreads) ((numThreads) + (numThreads) / 8 + 1)
19 #define MTCODER_THREADS_MAX 64
20 #define MTCODER_BLOCKS_MAX (MTCODER_GET_NUM_BLOCKS_FROM_THREADS(MTCODER_THREADS_MAX) + 3)
21#else
22 #define MTCODER_THREADS_MAX 1
23 #define MTCODER_BLOCKS_MAX 1
24#endif
25
26
27#ifndef Z7_ST
28
29
30typedef struct
31{
33 CMtProgress *mtProgress;
34 UInt64 inSize;
35 UInt64 outSize;
37
39
40#define MtProgressThunk_INIT(p) { (p)->inSize = 0; (p)->outSize = 0; }
41
42
43struct CMtCoder_;
44
45
46typedef struct
47{
48 struct CMtCoder_ *mtCoder;
49 unsigned index;
50 int stop;
51 Byte *inBuf;
52
53 CAutoResetEvent startEvent;
54 CThread thread;
56
57
58typedef struct
59{
60 SRes (*Code)(void *p, unsigned coderIndex, unsigned outBufIndex,
61 const Byte *src, size_t srcSize, int finished);
62 SRes (*Write)(void *p, unsigned outBufIndex);
64
65
66typedef struct
67{
68 SRes res;
69 unsigned bufIndex;
72
73
74typedef struct CMtCoder_
75{
76 /* input variables */
77
78 size_t blockSize; /* size of input block */
79 unsigned numThreadsMax;
81
82 ISeqInStreamPtr inStream;
83 const Byte *inData;
84 size_t inDataSize;
85
86 ICompressProgressPtr progress;
88
90 void *mtCallbackObject;
91
92
93 /* internal variables */
94
95 size_t allocatedBufsSize;
96
99
102
103 #ifdef MTCODER_USE_WRITE_THREAD
105 #else
108 unsigned writeIndex;
111 #endif
112
113 unsigned numStartedThreadsLimit;
114 unsigned numStartedThreads;
115
116 unsigned numBlocksMax;
117 unsigned blockIndex;
119
121
122 unsigned freeBlockHead;
124
129
130
134
135
136#endif
137
138
140
141#endif
int BoolInt
Definition 7zTypes.h:259
INT32 LONG
Definition 7zTypes.h:190
#define EXTERN_C_BEGIN
Definition 7zTypes.h:20
unsigned long long int UInt64
Definition 7zTypes.h:234
int SRes
Definition 7zTypes.h:45
#define EXTERN_C_END
Definition 7zTypes.h:21
void MtCoder_Construct(CMtCoder *p)
Definition MtCoder.c:343
void MtCoder_Destruct(CMtCoder *p)
Definition MtCoder.c:416
void MtProgressThunk_CreateVTable(CMtProgressThunk *p)
Definition MtCoder.c:29
struct CMtCoder_ CMtCoder
SRes MtCoder_Code(CMtCoder *p)
Definition MtCoder.c:425
#define Code
Definition deflate.h:80
char int srcSize
Definition lz4.h:806
const char * src
Definition lz4.h:866
#define MTCODER_BLOCKS_MAX
Definition MtCoder.h:20
#define MTCODER_THREADS_MAX
Definition MtCoder.h:19
Definition Threads.h:232
Definition Threads.h:186
Definition MtCoder.h:75
BoolInt stopReading
Definition MtCoder.h:100
unsigned numBlocksMax
Definition MtCoder.h:116
unsigned freeBlockList[MTCODER_BLOCKS_MAX]
Definition MtCoder.h:123
unsigned blockIndex
Definition MtCoder.h:117
CMtCoderBlock blocks[MTCODER_BLOCKS_MAX]
Definition MtCoder.h:126
size_t allocatedBufsSize
Definition MtCoder.h:95
Byte ReadyBlocks[MTCODER_BLOCKS_MAX]
Definition MtCoder.h:109
ISzAllocPtr allocBig
Definition MtCoder.h:87
UInt64 readProcessed
Definition MtCoder.h:118
unsigned freeBlockHead
Definition MtCoder.h:122
const Byte * inData
Definition MtCoder.h:83
CSemaphore blocksSemaphore
Definition MtCoder.h:98
CMtProgress mtProgress
Definition MtCoder.h:125
void * mtCallbackObject
Definition MtCoder.h:90
SRes readRes
Definition MtCoder.h:101
ICompressProgressPtr progress
Definition MtCoder.h:86
IMtCoderCallback2 * mtCallback
Definition MtCoder.h:89
unsigned writeIndex
Definition MtCoder.h:108
size_t blockSize
Definition MtCoder.h:78
LONG numFinishedThreads
Definition MtCoder.h:110
unsigned numStartedThreads
Definition MtCoder.h:114
CCriticalSection cs
Definition MtCoder.h:120
CMtCoderThread threads[MTCODER_THREADS_MAX]
Definition MtCoder.h:127
size_t inDataSize
Definition MtCoder.h:84
unsigned numStartedThreadsLimit
Definition MtCoder.h:113
SRes writeRes
Definition MtCoder.h:107
CAutoResetEvent readEvent
Definition MtCoder.h:97
CAutoResetEvent finishedEvent
Definition MtCoder.h:106
UInt64 expectedDataSize
Definition MtCoder.h:80
unsigned numThreadsMax
Definition MtCoder.h:79
ISeqInStreamPtr inStream
Definition MtCoder.h:82
Definition MtCoder.h:67
Definition MtCoder.h:47
Definition MtDec.h:25
Definition MtCoder.h:31
Definition Threads.h:212
Definition Threads.h:76
Definition 7zTypes.h:281
Definition MtCoder.h:59
Definition 7zTypes.h:460
uint finished
Definition dll.c:187
unsigned char Byte
Definition zconf.h:391