blob: 312dab91123cdbc600d04b6a6876ffcab428b1b0 (
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
|
#pragma once
#include <library/cpp/actors/util/contiguous_data.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()};
}
size_t GetCapacity() const override {
return Buffer.size();
}
};
} // namespace NActors
|