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

#include <ReadMostlySharedPtr.h>

Public Member Functions

 ReadMostlySharedPtr ()
 
 ReadMostlySharedPtr (const ReadMostlyWeakPtr< T, RefCount > &weakPtr)
 
 ReadMostlySharedPtr (const ReadMostlyMainPtr< T, RefCount > &mainPtr)
 
 ReadMostlySharedPtr (const ReadMostlySharedPtr &other)
 
ReadMostlySharedPtroperator= (const ReadMostlySharedPtr &other)
 
ReadMostlySharedPtroperator= (const ReadMostlyWeakPtr< T, RefCount > &other)
 
ReadMostlySharedPtroperator= (const ReadMostlyMainPtr< T, RefCount > &other)
 
 ReadMostlySharedPtr (ReadMostlySharedPtr &&other) noexcept
 
 ~ReadMostlySharedPtr () noexcept
 
ReadMostlySharedPtroperator= (ReadMostlySharedPtr &&other) noexcept
 
bool operator== (const ReadMostlyMainPtr< T, RefCount > &other) const
 
bool operator== (T *other) const
 
bool operator== (const ReadMostlySharedPtr< T, RefCount > &other) const
 
void reset ()
 
Tget () const
 
std::shared_ptr< TgetStdShared () const
 
Toperator* () const
 
Toperator-> () const
 
size_t use_count () const
 
bool unique () const
 
 operator bool () const
 

Private Member Functions

void reset (detail::ReadMostlySharedPtrCore< T, RefCount > *impl)
 

Private Attributes

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

Friends

class ReadMostlyWeakPtr< T, RefCount >
 

Detailed Description

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

Definition at line 30 of file ReadMostlySharedPtr.h.

Constructor & Destructor Documentation

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

Definition at line 254 of file ReadMostlySharedPtr.h.

254 {}
template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlySharedPtr< T, RefCount >::ReadMostlySharedPtr ( const ReadMostlyWeakPtr< T, RefCount > &  weakPtr)
inlineexplicit

Definition at line 256 of file ReadMostlySharedPtr.h.

256  {
257  reset(weakPtr.impl_);
258  }
template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlySharedPtr< T, RefCount >::ReadMostlySharedPtr ( const ReadMostlyMainPtr< T, RefCount > &  mainPtr)
inlineexplicit

Definition at line 261 of file ReadMostlySharedPtr.h.

261  {
262  reset(mainPtr.impl_);
263  }
template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlySharedPtr< T, RefCount >::ReadMostlySharedPtr ( const ReadMostlySharedPtr< T, RefCount > &  other)
inline

Definition at line 265 of file ReadMostlySharedPtr.h.

265  {
266  *this = other;
267  }
template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlySharedPtr< T, RefCount >::ReadMostlySharedPtr ( ReadMostlySharedPtr< T, RefCount > &&  other)
inlinenoexcept

Definition at line 284 of file ReadMostlySharedPtr.h.

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

Definition at line 288 of file ReadMostlySharedPtr.h.

288  {
289  reset(nullptr);
290  }

Member Function Documentation

template<typename T, typename RefCount = DefaultRefCount>
T* folly::ReadMostlySharedPtr< T, RefCount >::get ( ) const
inline
template<typename T, typename RefCount = DefaultRefCount>
std::shared_ptr<T> folly::ReadMostlySharedPtr< T, RefCount >::getStdShared ( ) const
inline

Definition at line 318 of file ReadMostlySharedPtr.h.

318  {
319  if (impl_) {
320  return impl_->getShared();
321  } else {
322  return {};
323  }
324  }
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_
template<typename T, typename RefCount = DefaultRefCount>
folly::ReadMostlySharedPtr< T, RefCount >::operator bool ( ) const
inlineexplicit

Definition at line 342 of file ReadMostlySharedPtr.h.

342  {
343  return impl_ != nullptr;
344  }
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_
template<typename T, typename RefCount = DefaultRefCount>
T& folly::ReadMostlySharedPtr< T, RefCount >::operator* ( ) const
inline

Definition at line 326 of file ReadMostlySharedPtr.h.

326  {
327  return *get();
328  }
template<typename T, typename RefCount = DefaultRefCount>
T* folly::ReadMostlySharedPtr< T, RefCount >::operator-> ( ) const
inline

Definition at line 330 of file ReadMostlySharedPtr.h.

330  {
331  return get();
332  }
template<typename T, typename RefCount = DefaultRefCount>
ReadMostlySharedPtr& folly::ReadMostlySharedPtr< T, RefCount >::operator= ( const ReadMostlySharedPtr< T, RefCount > &  other)
inline

Definition at line 269 of file ReadMostlySharedPtr.h.

269  {
270  reset(other.impl_);
271  return *this;
272  }
template<typename T, typename RefCount = DefaultRefCount>
ReadMostlySharedPtr& folly::ReadMostlySharedPtr< T, RefCount >::operator= ( const ReadMostlyWeakPtr< T, RefCount > &  other)
inline

Definition at line 274 of file ReadMostlySharedPtr.h.

274  {
275  reset(other.impl_);
276  return *this;
277  }
template<typename T, typename RefCount = DefaultRefCount>
ReadMostlySharedPtr& folly::ReadMostlySharedPtr< T, RefCount >::operator= ( const ReadMostlyMainPtr< T, RefCount > &  other)
inline

Definition at line 279 of file ReadMostlySharedPtr.h.

279  {
280  reset(other.impl_);
281  return *this;
282  }
template<typename T, typename RefCount = DefaultRefCount>
ReadMostlySharedPtr& folly::ReadMostlySharedPtr< T, RefCount >::operator= ( ReadMostlySharedPtr< T, RefCount > &&  other)
inlinenoexcept

Definition at line 292 of file ReadMostlySharedPtr.h.

292  {
293  std::swap(ptr_, other.ptr_);
294  std::swap(impl_, other.impl_);
295  return *this;
296  }
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
Definition: F14TestUtil.h:414
template<typename T, typename RefCount = DefaultRefCount>
bool folly::ReadMostlySharedPtr< T, RefCount >::operator== ( const ReadMostlyMainPtr< T, RefCount > &  other) const
inline

Definition at line 298 of file ReadMostlySharedPtr.h.

298  {
299  return get() == other.get();
300  }
template<typename T, typename RefCount = DefaultRefCount>
bool folly::ReadMostlySharedPtr< T, RefCount >::operator== ( T other) const
inline

Definition at line 302 of file ReadMostlySharedPtr.h.

302  {
303  return get() == other;
304  }
template<typename T, typename RefCount = DefaultRefCount>
bool folly::ReadMostlySharedPtr< T, RefCount >::operator== ( const ReadMostlySharedPtr< T, RefCount > &  other) const
inline

Definition at line 306 of file ReadMostlySharedPtr.h.

306  {
307  return get() == other.get();
308  }
template<typename T, typename RefCount = DefaultRefCount>
void folly::ReadMostlySharedPtr< T, RefCount >::reset ( )
inline

Definition at line 310 of file ReadMostlySharedPtr.h.

Referenced by TEST_F().

310  {
311  reset(nullptr);
312  }
template<typename T, typename RefCount = DefaultRefCount>
void folly::ReadMostlySharedPtr< T, RefCount >::reset ( detail::ReadMostlySharedPtrCore< T, RefCount > *  impl)
inlineprivate

Definition at line 349 of file ReadMostlySharedPtr.h.

349  {
350  if (impl_) {
351  impl_->decref();
352  impl_ = nullptr;
353  ptr_ = nullptr;
354  }
355 
356  if (impl && impl->incref()) {
357  impl_ = impl;
358  ptr_ = impl->get();
359  }
360  }
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_
template<typename T, typename RefCount = DefaultRefCount>
bool folly::ReadMostlySharedPtr< T, RefCount >::unique ( ) const
inline

Definition at line 338 of file ReadMostlySharedPtr.h.

338  {
339  return use_count() == 1;
340  }
template<typename T, typename RefCount = DefaultRefCount>
size_t folly::ReadMostlySharedPtr< T, RefCount >::use_count ( ) const
inline

Definition at line 334 of file ReadMostlySharedPtr.h.

334  {
335  return impl_->useCount();
336  }
detail::ReadMostlySharedPtrCore< T, RefCount > * impl_

Friends And Related Function Documentation

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

Definition at line 347 of file ReadMostlySharedPtr.h.

Member Data Documentation

template<typename T, typename RefCount = DefaultRefCount>
detail::ReadMostlySharedPtrCore<T, RefCount>* folly::ReadMostlySharedPtr< T, RefCount >::impl_ {nullptr}
private
template<typename T, typename RefCount = DefaultRefCount>
T* folly::ReadMostlySharedPtr< T, RefCount >::ptr_ {nullptr}
private

Definition at line 362 of file ReadMostlySharedPtr.h.


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