aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/Common/ProgressMt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Common/ProgressMt.cpp')
-rw-r--r--CPP/7zip/Common/ProgressMt.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/CPP/7zip/Common/ProgressMt.cpp b/CPP/7zip/Common/ProgressMt.cpp
new file mode 100644
index 0000000..c2714a2
--- /dev/null
+++ b/CPP/7zip/Common/ProgressMt.cpp
@@ -0,0 +1,53 @@
1// ProgressMt.h
2
3#include "StdAfx.h"
4
5#include "ProgressMt.h"
6
7void CMtCompressProgressMixer::Init(unsigned numItems, ICompressProgressInfo *progress)
8{
9 NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
10 InSizes.Clear();
11 OutSizes.Clear();
12 for (unsigned i = 0; i < numItems; i++)
13 {
14 InSizes.Add(0);
15 OutSizes.Add(0);
16 }
17 TotalInSize = 0;
18 TotalOutSize = 0;
19 _progress = progress;
20}
21
22void CMtCompressProgressMixer::Reinit(unsigned index)
23{
24 NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
25 InSizes[index] = 0;
26 OutSizes[index] = 0;
27}
28
29HRESULT CMtCompressProgressMixer::SetRatioInfo(unsigned index, const UInt64 *inSize, const UInt64 *outSize)
30{
31 NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
32 if (inSize)
33 {
34 UInt64 diff = *inSize - InSizes[index];
35 InSizes[index] = *inSize;
36 TotalInSize += diff;
37 }
38 if (outSize)
39 {
40 UInt64 diff = *outSize - OutSizes[index];
41 OutSizes[index] = *outSize;
42 TotalOutSize += diff;
43 }
44 if (_progress)
45 return _progress->SetRatioInfo(&TotalInSize, &TotalOutSize);
46 return S_OK;
47}
48
49
50STDMETHODIMP CMtCompressProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
51{
52 return _progress->SetRatioInfo(_index, inSize, outSize);
53}