blob: a221ae668b546b40152094c0e8e95755a3447841 (
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
|
#pragma once
#include <library/cpp/actors/util/rc_buf.h>
#include "shared_data.h"
namespace NActors {
class TRopeSharedDataBackend : public IContiguousChunk {
TSharedData Buffer;
public:
TRopeSharedDataBackend(TSharedData buffer)
: Buffer(std::move(buffer))
{}
TContiguousSpan GetData() const override {
return {Buffer.data(), Buffer.size()};
}
TMutableContiguousSpan GetDataMut() override {
if(Buffer.IsShared()) {
Buffer = TSharedData::Copy(Buffer.data(), Buffer.size());
}
return {Buffer.mutable_data(), Buffer.size()};
}
TMutableContiguousSpan UnsafeGetDataMut() override {
return {const_cast<char *>(Buffer.data()), Buffer.size()};
}
bool IsPrivate() const override {
return Buffer.IsPrivate();
}
size_t GetOccupiedMemorySize() const override {
return Buffer.size();
}
};
} // namespace NActors
|