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

Method DoNext

library/cpp/yt/memory/chunked_memory_pool_output.cpp:16–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14{ }
15
16size_t TChunkedMemoryPoolOutput::DoNext(void** ptr)
17{
18 // Check if the current chunk is exhausted.
19 if (Current_ == End_) {
20 // Emplace the (whole) last chunk, if any.
21 if (Begin_) {
22 Refs_.emplace_back(Begin_, Current_);
23 }
24 // Allocate a new chunk.
25 // Use |AllocateAligned| to get a chance to free some memory afterwards.
26 // Tune the number of bytes requested from the pool to try avoid allocations.
27 auto spareSize = Pool_->GetCurrentChunkSpareSize();
28 auto allocationSize = (spareSize == 0 ? ChunkSize_ : std::min(ChunkSize_, spareSize));
29 Begin_ = Pool_->AllocateAligned(allocationSize, /* align */ 1);
30 Current_ = Begin_;
31 End_ = Begin_ + allocationSize;
32 }
33
34 // Return the unused part of the current chunk.
35 // This could be the whole chunk allocated above.
36 *ptr = Current_;
37 auto size = End_ - Current_;
38 Current_ = End_;
39 return size;
40}
41
42void TChunkedMemoryPoolOutput::DoUndo(size_t size)
43{

Callers

nothing calls this directly

Calls 4

minFunction · 0.50
emplace_backMethod · 0.45
AllocateAlignedMethod · 0.45

Tested by

no test coverage detected