proxygen
folly::ReadMostlyMainPtr< T, RefCount > Class Template Reference

#include <ReadMostlySharedPtr.h>

Public Member Functions

 ReadMostlyMainPtr ()
 
 ReadMostlyMainPtr (std::shared_ptr< T > ptr)
 
 ReadMostlyMainPtr (const ReadMostlyMainPtr &)=delete
 
ReadMostlyMainPtroperator= (const ReadMostlyMainPtr &)=delete
 
 ReadMostlyMainPtr (ReadMostlyMainPtr &&other) noexcept
 
ReadMostlyMainPtroperator= (ReadMostlyMainPtr &&other) noexcept
 
bool operator== (const ReadMostlyMainPtr< T, RefCount > &other) const
 
bool operator== (T *other) const
 
bool operator== (const ReadMostlySharedPtr< T, RefCount > &other) const
 
 ~ReadMostlyMainPtr () noexcept
 
void reset () noexcept
 
void reset (std::shared_ptr< T > ptr)
 
Tget () const
 
std::shared_ptr< TgetStdShared () const
 
Toperator* () const
 
Toperator-> () const
 
ReadMostlySharedPtr< T, RefCount > getShared () const
 
 operator bool () const
 

Private Attributes

detail::ReadMostlySharedPtrCore< T, RefCount > * impl_ {nullptr}
 

Friends

class ReadMostlyWeakPtr< T, RefCount >
 
class ReadMostlySharedPtr< T, RefCount >
 
class ReadMostlyMainPtrDeleter< RefCount >
 

Detailed Description

template<typename T, typename RefCount = DefaultRefCount>
class folly::ReadMostlyMainPtr< T, RefCount >

Definition at line 26 of file ReadMostlySharedPtr.h.

Constructor & Destructor Documentation

template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlyMainPtr< T, RefCount >::ReadMostlyMainPtr ( )
inline

Definition at line 100 of file ReadMostlySharedPtr.h.

100 {}
template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlyMainPtr< T, RefCount >::ReadMostlyMainPtr ( std::shared_ptr< T ptr)
inlineexplicit

Definition at line 102 of file ReadMostlySharedPtr.h.

102  {
103  reset(std::move(ptr));
104  }
void * ptr
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlyMainPtr< T, RefCount >::ReadMostlyMainPtr ( const ReadMostlyMainPtr< T, RefCount > &  )
delete
template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlyMainPtr< T, RefCount >::ReadMostlyMainPtr ( ReadMostlyMainPtr< T, RefCount > &&  other)
inlinenoexcept

Definition at line 109 of file ReadMostlySharedPtr.h.

109  {
110  *this = std::move(other);
111  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlyMainPtr< T, RefCount >::~ReadMostlyMainPtr ( )
inlinenoexcept

Definition at line 131 of file ReadMostlySharedPtr.h.

131  {
132  reset();
133  }

Member Function Documentation

template<typename T, typename RefCount = DefaultRefCount>
T* folly::ReadMostlyMainPtr< T, RefCount >::get ( ) const
inline

Definition at line 151 of file ReadMostlySharedPtr.h.

Referenced by folly::ReadMostlyMainPtr< T >::operator==(), folly::ReadMostlySharedPtr< T >::operator==(), folly::operator==(), and TEST_F().

151  {
152  if (impl_) {
153  return impl_->ptrRaw_;
154  } else {
155  return nullptr;
156  }
157  }
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_
template<typename T, typename RefCount = DefaultRefCount>
ReadMostlySharedPtr<T, RefCount> folly::ReadMostlyMainPtr< T, RefCount >::getShared ( ) const
inline

Definition at line 175 of file ReadMostlySharedPtr.h.

Referenced by TEST_F().

175  {
176  return ReadMostlySharedPtr<T, RefCount>(*this);
177  }
friend class ReadMostlySharedPtr< T, RefCount >
template<typename T, typename RefCount = DefaultRefCount>
std::shared_ptr<T> folly::ReadMostlyMainPtr< T, RefCount >::getStdShared ( ) const
inline

Definition at line 159 of file ReadMostlySharedPtr.h.

Referenced by TEST_F().

159  {
160  if (impl_) {
161  return impl_->getShared();
162  } else {
163  return {};
164  }
165  }
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_
template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlyMainPtr< T, RefCount >::operator bool ( ) const
inlineexplicit

Definition at line 179 of file ReadMostlySharedPtr.h.

179  {
180  return impl_ != nullptr;
181  }
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_
template<typename T, typename RefCount = DefaultRefCount>
T& folly::ReadMostlyMainPtr< T, RefCount >::operator* ( ) const
inline

Definition at line 167 of file ReadMostlySharedPtr.h.

167  {
168  return *get();
169  }
template<typename T, typename RefCount = DefaultRefCount>
T* folly::ReadMostlyMainPtr< T, RefCount >::operator-> ( ) const
inline

Definition at line 171 of file ReadMostlySharedPtr.h.

171  {
172  return get();
173  }
template<typename T, typename RefCount = DefaultRefCount>
ReadMostlyMainPtr& folly::ReadMostlyMainPtr< T, RefCount >::operator= ( const ReadMostlyMainPtr< T, RefCount > &  )
delete
template<typename T, typename RefCount = DefaultRefCount>
ReadMostlyMainPtr& folly::ReadMostlyMainPtr< T, RefCount >::operator= ( ReadMostlyMainPtr< T, RefCount > &&  other)
inlinenoexcept

Definition at line 113 of file ReadMostlySharedPtr.h.

113  {
114  std::swap(impl_, other.impl_);
115 
116  return *this;
117  }
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
Definition: F14TestUtil.h:414
template<typename T, typename RefCount = DefaultRefCount>
bool folly::ReadMostlyMainPtr< T, RefCount >::operator== ( const ReadMostlyMainPtr< T, RefCount > &  other) const
inline

Definition at line 119 of file ReadMostlySharedPtr.h.

119  {
120  return get() == other.get();
121  }
template<typename T, typename RefCount = DefaultRefCount>
bool folly::ReadMostlyMainPtr< T, RefCount >::operator== ( T other) const
inline

Definition at line 123 of file ReadMostlySharedPtr.h.

123  {
124  return get() == other;
125  }
template<typename T, typename RefCount = DefaultRefCount>
bool folly::ReadMostlyMainPtr< T, RefCount >::operator== ( const ReadMostlySharedPtr< T, RefCount > &  other) const
inline

Definition at line 127 of file ReadMostlySharedPtr.h.

127  {
128  return get() == other.get();
129  }
template<typename T, typename RefCount = DefaultRefCount>
void folly::ReadMostlyMainPtr< T, RefCount >::reset ( )
inlinenoexcept

Definition at line 135 of file ReadMostlySharedPtr.h.

Referenced by folly::detail::SingletonHolder< T >::createInstance(), and TEST_F().

135  {
136  if (impl_) {
137  impl_->count_.useGlobal();
138  impl_->weakCount_.useGlobal();
139  impl_->decref();
140  impl_ = nullptr;
141  }
142  }
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_
template<typename T, typename RefCount = DefaultRefCount>
void folly::ReadMostlyMainPtr< T, RefCount >::reset ( std::shared_ptr< T ptr)
inline

Definition at line 144 of file ReadMostlySharedPtr.h.

144  {
145  reset();
146  if (ptr) {
147  impl_ = new detail::ReadMostlySharedPtrCore<T, RefCount>(std::move(ptr));
148  }
149  }
void * ptr
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_

Friends And Related Function Documentation

template<typename T, typename RefCount = DefaultRefCount>
friend class ReadMostlyMainPtrDeleter< RefCount >
friend

Definition at line 186 of file ReadMostlySharedPtr.h.

template<typename T, typename RefCount = DefaultRefCount>
friend class ReadMostlySharedPtr< T, RefCount >
friend

Definition at line 185 of file ReadMostlySharedPtr.h.

template<typename T, typename RefCount = DefaultRefCount>
friend class ReadMostlyWeakPtr< T, RefCount >
friend

Definition at line 184 of file ReadMostlySharedPtr.h.

Member Data Documentation


The documentation for this class was generated from the following file: