1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2MT.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,121 @@ 1.4 +// CoderMixer2MT.h 1.5 + 1.6 +#ifndef __CODER_MIXER2_MT_H 1.7 +#define __CODER_MIXER2_MT_H 1.8 + 1.9 +#include "CoderMixer2.h" 1.10 +#include "../../../Common/MyCom.h" 1.11 +#include "../../../Windows/Thread.h" 1.12 +#include "../../Common/StreamBinder.h" 1.13 + 1.14 +namespace NCoderMixer2 { 1.15 + 1.16 +// CreateEvents(); 1.17 +// { 1.18 +// SetCoderInfo() 1.19 +// Init Streams 1.20 +// set CompressEvent() 1.21 +// wait CompressionCompletedEvent 1.22 +// } 1.23 + 1.24 +struct CThreadCoderInfo: public CCoderInfo 1.25 +{ 1.26 + NWindows::NSynchronization::CAutoResetEvent *CompressEvent; 1.27 + HANDLE ExitEvent; 1.28 + NWindows::NSynchronization::CAutoResetEvent *CompressionCompletedEvent; 1.29 + 1.30 + CObjectVector< CMyComPtr<ISequentialInStream> > InStreams; 1.31 + CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams; 1.32 + CRecordVector<ISequentialInStream *> InStreamPointers; 1.33 + CRecordVector<ISequentialOutStream *> OutStreamPointers; 1.34 + 1.35 + CMyComPtr<ICompressProgressInfo> Progress; // CMyComPtr 1.36 + HRESULT Result; 1.37 + 1.38 + CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams); 1.39 + void SetCoderInfo(const UInt64 **inSizes, 1.40 + const UInt64 **outSizes, ICompressProgressInfo *progress); 1.41 + ~CThreadCoderInfo(); 1.42 + bool WaitAndCode(); 1.43 + void CreateEvents(); 1.44 +}; 1.45 + 1.46 + 1.47 +// SetBindInfo() 1.48 +// for each coder 1.49 +// { 1.50 +// AddCoder[2]() 1.51 +// } 1.52 +// 1.53 +// for each file 1.54 +// { 1.55 +// ReInit() 1.56 +// for each coder 1.57 +// { 1.58 +// SetCoderInfo 1.59 +// } 1.60 +// SetProgressIndex(UInt32 coderIndex); 1.61 +// Code 1.62 +// } 1.63 + 1.64 + 1.65 +class CCoderMixer2MT: 1.66 + public ICompressCoder2, 1.67 + public CCoderMixer2, 1.68 + public CMyUnknownImp 1.69 +{ 1.70 + MY_UNKNOWN_IMP 1.71 + 1.72 +public: 1.73 + STDMETHOD(Init)(ISequentialInStream **inStreams, 1.74 + ISequentialOutStream **outStreams); 1.75 + 1.76 + STDMETHOD(Code)(ISequentialInStream **inStreams, 1.77 + const UInt64 **inSizes, 1.78 + UInt32 numInStreams, 1.79 + ISequentialOutStream **outStreams, 1.80 + const UInt64 **outSizes, 1.81 + UInt32 numOutStreams, 1.82 + ICompressProgressInfo *progress); 1.83 + 1.84 + 1.85 + CCoderMixer2MT(); 1.86 + ~CCoderMixer2MT(); 1.87 + void AddCoderCommon(); 1.88 + void AddCoder(ICompressCoder *coder); 1.89 + void AddCoder2(ICompressCoder2 *coder); 1.90 + 1.91 + void ReInit(); 1.92 + void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) 1.93 + { _coderInfoVector[coderIndex].SetCoderInfo(inSizes, outSizes, NULL); } 1.94 + void SetProgressCoderIndex(UInt32 coderIndex) 1.95 + { _progressCoderIndex = coderIndex; } 1.96 + 1.97 + 1.98 + UInt64 GetWriteProcessedSize(UInt32 binderIndex) const; 1.99 + 1.100 + 1.101 + bool MyCode(); 1.102 + 1.103 +private: 1.104 + CBindInfo _bindInfo; 1.105 + CObjectVector<CStreamBinder> _streamBinders; 1.106 + CObjectVector<CThreadCoderInfo> _coderInfoVector; 1.107 + CRecordVector<NWindows::CThread> _threads; 1.108 + NWindows::CThread _mainThread; 1.109 + 1.110 + NWindows::NSynchronization::CAutoResetEvent _startCompressingEvent; 1.111 + CRecordVector<HANDLE> _compressingCompletedEvents; 1.112 + NWindows::NSynchronization::CAutoResetEvent _compressingFinishedEvent; 1.113 + 1.114 + NWindows::NSynchronization::CManualResetEvent _exitEvent; 1.115 + UInt32 _progressCoderIndex; 1.116 + 1.117 +public: 1.118 + void SetBindInfo(const CBindInfo &bindInfo); 1.119 + 1.120 +}; 1.121 + 1.122 +} 1.123 +#endif 1.124 +