MCPcopy Create free account
hub / github.com/catboost/catboost / PrepareRead

Method PrepareRead

library/cpp/threading/chunk_queue/queue.h:189–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187 }
188
189 T* PrepareRead() {
190 TChunk* chunk = Reader.Chunk;
191 Y_ASSERT(chunk);
192
193 for (;;) {
194 size_t writerCount = AtomicGet(chunk->Count);
195 if (Reader.Count != writerCount) {
196 return chunk->GetPtr(Reader.Count);
197 }
198
199 if (writerCount != TChunk::MaxCount) {
200 return nullptr;
201 }
202
203 chunk = AtomicGet(chunk->Next);
204 if (!chunk) {
205 return nullptr;
206 }
207
208 delete Reader.Chunk;
209 Reader.Chunk = chunk;
210 Reader.Count = 0;
211 }
212 }
213
214 void CompleteRead() {
215 ++Reader.Count;

Callers 1

PrepareReadMethod · 0.45

Calls 2

AtomicGetFunction · 0.50
GetPtrMethod · 0.45

Tested by

no test coverage detected