blob: 774b21788e7bd1445bfadb4044ef64d82e2d95b0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
|