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

Class TSharedRef

library/cpp/yt/memory/ref.h:114–194  ·  view source on GitHub ↗

A reference to a range of memory with shared ownership.

Source from the content-addressed store, hash-verified

112
113//! A reference to a range of memory with shared ownership.
114class TSharedRef
115 : public TSharedRange<char>
116{
117public:
118 //! Creates a null TSharedRef.
119 TSharedRef() = default;
120
121 //! Creates a TSharedRef with a given holder.
122 TSharedRef(TRef ref, TSharedRangeHolderPtr holder);
123
124 //! Creates a TSharedRef from a pointer and length.
125 TSharedRef(const void* data, size_t length, TSharedRangeHolderPtr holder);
126
127 //! Creates a TSharedRef from a range.
128 TSharedRef(const void* begin, const void* end, TSharedRangeHolderPtr holder);
129
130 //! Creates an empty TSharedRef.
131 static TSharedRef MakeEmpty();
132
133 //! Converts a TSharedRef to TRef.
134 operator TRef() const;
135
136
137 //! Creates a TSharedRef from TString.
138 //! Since strings are ref-counted, no data is being copied.
139 //! The memory is marked with a given tag.
140 template <class TTag>
141 static TSharedRef FromString(TString str);
142
143 //! Same as above but the memory is marked with TDefaultSharedBlobTag.
144 static TSharedRef FromString(TString str);
145
146 //! Same as above but the memory tag is specified in #tagCookie.
147 static TSharedRef FromString(TString str, TRefCountedTypeCookie tagCookie);
148
149 //! Creates a TSharedRef from std::string.
150 //! No data is being copied in #FromString itself but since #str is passed by value
151 //! a copy may occur at caller's side.
152 //! The memory is marked with a given tag.
153 template <class TTag>
154 static TSharedRef FromString(std::string str);
155
156 //! Same as above but the memory is marked with TDefaultSharedBlobTag.
157 static TSharedRef FromString(std::string str);
158
159 //! Same as above but the memory tag is specified in #tagCookie.
160 static TSharedRef FromString(std::string str, TRefCountedTypeCookie tagCookie);
161
162 //! Creates a TSharedRef from a zero-terminated C string.
163 static TSharedRef FromString(const char* str);
164
165 //! Creates a TSharedRef for a given blob taking ownership of its content.
166 static TSharedRef FromBlob(TBlob&& blob);
167
168 //! Converts to TStringBuf.
169 TStringBuf ToStringBuf() const;
170
171 //! Creates a copy of a given TRef.

Callers 6

MakeEmptyMethod · 0.85
SliceMethod · 0.85
operator TSharedRefMethod · 0.85
FromStringImplMethod · 0.85
FromBlobMethod · 0.85
ToSharedRefMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected