13 #ifndef __PROCESS_OWNED_HPP__ 14 #define __PROCESS_OWNED_HPP__ 20 #include <glog/logging.h> 41 Owned(std::nullptr_t) :
Owned(static_cast<T*>(nullptr)) {};
44 bool operator<(const Owned<T>& that)
const;
71 std::shared_ptr<Data> data;
83 data.reset(
new Data(t));
91 return data == that.data;
98 return data < that.data;
102 template <
typename T>
105 return *CHECK_NOTNULL(
get());
109 template <
typename T>
112 return CHECK_NOTNULL(
get());
116 template <
typename T>
119 if (data ==
nullptr) {
123 CHECK(data->t != static_cast<T*>(
nullptr))
124 <<
"This owned pointer has already been shared";
131 template <
typename T>
138 template <
typename T>
144 data.reset(
new Data(t));
149 template <
typename T>
152 data.swap(that.data);
156 template <
typename T>
159 if (data ==
nullptr) {
165 T* old = data->t.exchange(
nullptr);
166 if (old ==
nullptr) {
176 template <
typename T>
179 if (data ==
nullptr) {
185 T* old = data->t.exchange(
nullptr);
186 if (old ==
nullptr) {
196 template <
typename T>
198 : t(CHECK_NOTNULL(_t)) {}
201 template <
typename T>
209 #endif // __PROCESS_OWNED_HPP__ void reset()
Definition: owned.hpp:132
void reset()
Definition: shared.hpp:136
T * get() const
Definition: owned.hpp:117
bool operator==(const Owned< T > &that) const
Definition: owned.hpp:89
T * operator->() const
Definition: owned.hpp:110
Owned()
Definition: owned.hpp:76
bool operator<(const Owned< T > &that) const
Definition: owned.hpp:96
Shared< T > share()
Definition: owned.hpp:157
Owned(std::nullptr_t)
Definition: owned.hpp:41
Definition: executor.hpp:48
T & operator*() const
Definition: owned.hpp:103
T * release()
Definition: owned.hpp:177
void swap(Owned< T > &that)
Definition: owned.hpp:150