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

Class TMappedAllocation

util/system/filemap.h:291–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289};
290
291class TMappedAllocation: TMoveOnly {
292public:
293 TMappedAllocation(size_t size = 0, bool shared = false, void* addr = nullptr);
294 ~TMappedAllocation() {
295 Dealloc();
296 }
297 TMappedAllocation(TMappedAllocation&& other) noexcept {
298 this->swap(other);
299 }
300 TMappedAllocation& operator=(TMappedAllocation&& other) noexcept {
301 this->swap(other);
302 return *this;
303 }
304 void* Alloc(size_t size, void* addr = nullptr);
305 void Dealloc();
306 void* Ptr() const {
307 return Ptr_;
308 }
309 char* Data(ui32 pos = 0) const {
310 return (char*)(Ptr_ ? ((char*)Ptr_ + pos) : nullptr);
311 }
312 char* Begin() const noexcept {
313 return (char*)Ptr();
314 }
315 char* End() const noexcept {
316 return Begin() + MappedSize();
317 }
318 size_t MappedSize() const {
319 return Size_;
320 }
321 void swap(TMappedAllocation& with) noexcept;
322
323private:
324 void* Ptr_ = nullptr;
325 size_t Size_ = 0;
326 bool Shared_ = false;
327#ifdef _win_
328 void* Mapping_ = nullptr;
329#endif
330};
331
332template <class T>
333class TMappedArray: private TMappedAllocation {

Callers

nothing calls this directly

Calls 1

swapMethod · 0.95

Tested by

no test coverage detected