MCPcopy Create free account
hub / github.com/3rdparty/libprocess / own

Method own

include/process/shared.hpp:161–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159
160template <typename T>
161Future<Owned<T>> Shared<T>::own()
162{
163 // If two threads simultaneously access this object and at least one
164 // of them is a write, the behavior is undefined. This is similar to
165 // boost::shared_ptr. For more details, please refer to the boost
166 // shared_ptr document (section "Thread Safety").
167 if (data == nullptr) {
168 return Owned<T>(nullptr);
169 }
170
171 bool false_value = false;
172 if (!data->owned.compare_exchange_strong(false_value, true)) {
173 return Failure("Ownership has already been transferred");
174 }
175
176 Future<Owned<T>> future = data->promise.future();
177 data.reset();
178 return future;
179}
180
181
182template <typename T>

Callers 1

TESTFunction · 0.80

Calls 3

FailureClass · 0.85
futureMethod · 0.80
resetMethod · 0.45

Tested by 1

TESTFunction · 0.64