MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / Unpack5MT

Method Unpack5MT

Libraries/unrar/unpack50mt.cpp:56–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55
56void Unpack::Unpack5MT(bool Solid)
57{
58 InitMT();
59 UnpInitData(Solid);
60
61 for (uint I=0;I<MaxUserThreads*UNP_BLOCKS_PER_THREAD;I++)
62 {
63 UnpackThreadData *CurData=UnpThreadData+I;
64 CurData->LargeBlock=false;
65 CurData->Incomplete=false;
66 }
67
68 UnpThreadData[0].BlockHeader=BlockHeader;
69 UnpThreadData[0].BlockTables=BlockTables;
70 uint LastBlockNum=0;
71
72 int DataSize=0;
73 int BlockStart=0;
74
75
76 // 'true' if we found a block too large for multithreaded extraction,
77 // so we switched to single threaded mode until the end of file.
78 // Large blocks could cause too high memory use in multithreaded mode.
79 bool LargeBlock=false;
80
81 bool Done=false;
82 while (!Done)
83 {
84 // Data amount, which is guaranteed to fit block header and tables,
85 // so we can safely read them without additional checks.
86 const int TooSmallToProcess=1024;
87
88 int ReadSize=UnpIO->UnpRead(ReadBufMT+DataSize,(UNP_READ_SIZE_MT-DataSize)&~0xf);
89 if (ReadSize<0)
90 break;
91 DataSize+=ReadSize;
92 if (DataSize==0)
93 break;
94
95 // First read chunk can be small if we are near the end of volume
96 // and we want it to fit block header and tables.
97 if (ReadSize>0 && DataSize<TooSmallToProcess)
98 continue;
99
100 while (BlockStart<DataSize && !Done)
101 {
102 uint BlockNumber=0,BlockNumberMT=0;
103 while (BlockNumber<MaxUserThreads*UNP_BLOCKS_PER_THREAD)
104 {
105 UnpackThreadData *CurData=UnpThreadData+BlockNumber;
106 LastBlockNum=BlockNumber;
107 CurData->UnpackPtr=this;
108
109 // 'Incomplete' thread is present. This is a thread processing block
110 // in the end of buffer, split between two read operations.
111 if (CurData->Incomplete)
112 CurData->DataSize=DataSize;
113 else

Callers

nothing calls this directly

Calls 5

UnpReadMethod · 0.80
SetExternalBufferMethod · 0.80
InitBitInputMethod · 0.80
AddTaskMethod · 0.80
WaitDoneMethod · 0.80

Tested by

no test coverage detected