michael@0: // CoderMixer2MT.h michael@0: michael@0: #ifndef __CODER_MIXER2_MT_H michael@0: #define __CODER_MIXER2_MT_H michael@0: michael@0: #include "CoderMixer2.h" michael@0: #include "../../../Common/MyCom.h" michael@0: #include "../../../Windows/Thread.h" michael@0: #include "../../Common/StreamBinder.h" michael@0: michael@0: namespace NCoderMixer2 { michael@0: michael@0: // CreateEvents(); michael@0: // { michael@0: // SetCoderInfo() michael@0: // Init Streams michael@0: // set CompressEvent() michael@0: // wait CompressionCompletedEvent michael@0: // } michael@0: michael@0: struct CThreadCoderInfo: public CCoderInfo michael@0: { michael@0: NWindows::NSynchronization::CAutoResetEvent *CompressEvent; michael@0: HANDLE ExitEvent; michael@0: NWindows::NSynchronization::CAutoResetEvent *CompressionCompletedEvent; michael@0: michael@0: CObjectVector< CMyComPtr > InStreams; michael@0: CObjectVector< CMyComPtr > OutStreams; michael@0: CRecordVector InStreamPointers; michael@0: CRecordVector OutStreamPointers; michael@0: michael@0: CMyComPtr Progress; // CMyComPtr michael@0: HRESULT Result; michael@0: michael@0: CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams); michael@0: void SetCoderInfo(const UInt64 **inSizes, michael@0: const UInt64 **outSizes, ICompressProgressInfo *progress); michael@0: ~CThreadCoderInfo(); michael@0: bool WaitAndCode(); michael@0: void CreateEvents(); michael@0: }; michael@0: michael@0: michael@0: // SetBindInfo() michael@0: // for each coder michael@0: // { michael@0: // AddCoder[2]() michael@0: // } michael@0: // michael@0: // for each file michael@0: // { michael@0: // ReInit() michael@0: // for each coder michael@0: // { michael@0: // SetCoderInfo michael@0: // } michael@0: // SetProgressIndex(UInt32 coderIndex); michael@0: // Code michael@0: // } michael@0: michael@0: michael@0: class CCoderMixer2MT: michael@0: public ICompressCoder2, michael@0: public CCoderMixer2, michael@0: public CMyUnknownImp michael@0: { michael@0: MY_UNKNOWN_IMP michael@0: michael@0: public: michael@0: STDMETHOD(Init)(ISequentialInStream **inStreams, michael@0: ISequentialOutStream **outStreams); michael@0: michael@0: STDMETHOD(Code)(ISequentialInStream **inStreams, michael@0: const UInt64 **inSizes, michael@0: UInt32 numInStreams, michael@0: ISequentialOutStream **outStreams, michael@0: const UInt64 **outSizes, michael@0: UInt32 numOutStreams, michael@0: ICompressProgressInfo *progress); michael@0: michael@0: michael@0: CCoderMixer2MT(); michael@0: ~CCoderMixer2MT(); michael@0: void AddCoderCommon(); michael@0: void AddCoder(ICompressCoder *coder); michael@0: void AddCoder2(ICompressCoder2 *coder); michael@0: michael@0: void ReInit(); michael@0: void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) michael@0: { _coderInfoVector[coderIndex].SetCoderInfo(inSizes, outSizes, NULL); } michael@0: void SetProgressCoderIndex(UInt32 coderIndex) michael@0: { _progressCoderIndex = coderIndex; } michael@0: michael@0: michael@0: UInt64 GetWriteProcessedSize(UInt32 binderIndex) const; michael@0: michael@0: michael@0: bool MyCode(); michael@0: michael@0: private: michael@0: CBindInfo _bindInfo; michael@0: CObjectVector _streamBinders; michael@0: CObjectVector _coderInfoVector; michael@0: CRecordVector _threads; michael@0: NWindows::CThread _mainThread; michael@0: michael@0: NWindows::NSynchronization::CAutoResetEvent _startCompressingEvent; michael@0: CRecordVector _compressingCompletedEvents; michael@0: NWindows::NSynchronization::CAutoResetEvent _compressingFinishedEvent; michael@0: michael@0: NWindows::NSynchronization::CManualResetEvent _exitEvent; michael@0: UInt32 _progressCoderIndex; michael@0: michael@0: public: michael@0: void SetBindInfo(const CBindInfo &bindInfo); michael@0: michael@0: }; michael@0: michael@0: } michael@0: #endif michael@0: