diff options
author | babenko <babenko@yandex-team.com> | 2023-01-03 13:23:49 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2023-01-03 13:23:49 +0300 |
commit | 85dbae30a801094e01a9aa5e4ecb1be070420ed4 (patch) | |
tree | 1381aac9994baae96382a5231e8b1596d876320f /library/cpp/yt/memory/chunked_memory_pool_output.h | |
parent | 8ee4eaa91898ce3adcdf302ba33311fc9e627282 (diff) | |
download | ydb-85dbae30a801094e01a9aa5e4ecb1be070420ed4.tar.gz |
More TChunkedMemoryPool, TChunkedMemoryAllocator, TChunkedMemoryPoolOutput to library
More TChunkedMemoryPool, TChunkedMemoryAllocator, TChunkedMemoryPoolOutput to library
wip
Diffstat (limited to 'library/cpp/yt/memory/chunked_memory_pool_output.h')
-rw-r--r-- | library/cpp/yt/memory/chunked_memory_pool_output.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/library/cpp/yt/memory/chunked_memory_pool_output.h b/library/cpp/yt/memory/chunked_memory_pool_output.h new file mode 100644 index 0000000000..774b21788e --- /dev/null +++ b/library/cpp/yt/memory/chunked_memory_pool_output.h @@ -0,0 +1,43 @@ +#pragma once + +#include "public.h" +#include "ref.h" + +#include <util/stream/zerocopy_output.h> + +#include <util/generic/size_literals.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +class TChunkedMemoryPoolOutput + : public IZeroCopyOutput +{ +public: + static constexpr size_t DefaultChunkSize = 4_KB; + + explicit TChunkedMemoryPoolOutput( + TChunkedMemoryPool* pool, + size_t chunkSize = DefaultChunkSize); + + std::vector<TMutableRef> Finish(); + +private: + size_t DoNext(void** ptr) override; + void DoUndo(size_t size) override; + +private: + TChunkedMemoryPool* const Pool_; + const size_t ChunkSize_; + + char* Begin_ = nullptr; + char* Current_ = nullptr; + char* End_ = nullptr; + std::vector<TMutableRef> Refs_; +}; + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT + |