13 #ifndef __PROCESS_SHARED_HPP__ 14 #define __PROCESS_SHARED_HPP__ 20 #include <glog/logging.h> 41 bool operator<(const Shared<T>& that)
const;
68 std::atomic_bool owned;
72 std::shared_ptr<Data> data;
84 data.reset(
new Data(t));
92 return data == that.data;
99 return data < that.data;
103 template <
typename T>
106 return *CHECK_NOTNULL(
get());
110 template <
typename T>
113 return CHECK_NOTNULL(
get());
117 template <
typename T>
120 if (data ==
nullptr) {
128 template <
typename T>
131 return data.unique();
135 template <
typename T>
142 template <
typename T>
148 data.reset(
new Data(t));
153 template <
typename T>
156 data.swap(that.data);
160 template <
typename T>
167 if (data ==
nullptr) {
171 bool false_value =
false;
172 if (!data->owned.compare_exchange_strong(false_value,
true)) {
173 return Failure(
"Ownership has already been transferred");
182 template <
typename T>
184 : t(CHECK_NOTNULL(_t)), owned(
false) {}
187 template <
typename T>
199 #endif // __PROCESS_SHARED_HPP__ Definition: future.hpp:668
void reset()
Definition: shared.hpp:136
bool operator<(const Shared< T > &that) const
Definition: shared.hpp:97
bool operator==(const Shared< T > &that) const
Definition: shared.hpp:90
bool unique() const
Definition: shared.hpp:129
Definition: future.hpp:74
Protocol< PromiseRequest, PromiseResponse > promise
Shared(std::nullptr_t)
Definition: shared.hpp:38
const T * operator->() const
Definition: shared.hpp:111
Definition: executor.hpp:48
Shared()
Definition: shared.hpp:77
const T & operator*() const
Definition: shared.hpp:104
Future< Owned< T > > own()
Definition: shared.hpp:161
const T * get() const
Definition: shared.hpp:118
void swap(Shared< T > &that)
Definition: shared.hpp:154
Definition: future.hpp:58