1 /* MtCoder.h -- Multi-thread Coder
\r
2 2009-11-19 : Igor Pavlov : Public domain */
\r
14 CAutoResetEvent startEvent;
\r
15 CAutoResetEvent finishedEvent;
\r
18 THREAD_FUNC_TYPE func;
\r
20 THREAD_FUNC_RET_TYPE res;
\r
23 void LoopThread_Construct(CLoopThread *p);
\r
24 void LoopThread_Close(CLoopThread *p);
\r
25 WRes LoopThread_Create(CLoopThread *p);
\r
26 WRes LoopThread_StopAndWait(CLoopThread *p);
\r
27 WRes LoopThread_StartSubThread(CLoopThread *p);
\r
28 WRes LoopThread_WaitSubThread(CLoopThread *p);
\r
31 #define NUM_MT_CODER_THREADS_MAX 32
\r
33 #define NUM_MT_CODER_THREADS_MAX 1
\r
39 UInt64 totalOutSize;
\r
40 ICompressProgress *progress;
\r
42 CCriticalSection cs;
\r
43 UInt64 inSizes[NUM_MT_CODER_THREADS_MAX];
\r
44 UInt64 outSizes[NUM_MT_CODER_THREADS_MAX];
\r
47 SRes MtProgress_Set(CMtProgress *p, unsigned index, UInt64 inSize, UInt64 outSize);
\r
53 struct _CMtCoder *mtCoder;
\r
63 CAutoResetEvent canRead;
\r
64 CAutoResetEvent canWrite;
\r
69 SRes (*Code)(void *p, unsigned index, Byte *dest, size_t *destSize,
\r
70 const Byte *src, size_t srcSize, int finished);
\r
73 typedef struct _CMtCoder
\r
76 size_t destBlockSize;
\r
77 unsigned numThreads;
\r
79 ISeqInStream *inStream;
\r
80 ISeqOutStream *outStream;
\r
81 ICompressProgress *progress;
\r
84 IMtCoderCallback *mtCallback;
\r
85 CCriticalSection cs;
\r
88 CMtProgress mtProgress;
\r
89 CMtThread threads[NUM_MT_CODER_THREADS_MAX];
\r
92 void MtCoder_Construct(CMtCoder* p);
\r
93 void MtCoder_Destruct(CMtCoder* p);
\r
94 SRes MtCoder_Code(CMtCoder *p);
\r