proxygen
folly::PackedSyncPtr< T > Class Template Reference

#include <PackedSyncPtr.h>

Public Member Functions

void init (T *initialPtr=nullptr, uint16_t initialExtra=0)
 
void set (T *t)
 
Tget () const
 
Toperator-> () const
 
reference operator* () const
 
reference operator[] (std::ptrdiff_t i) const
 
void lock () const
 
void unlock () const
 
bool try_lock () const
 
uint16_t extra () const
 
void setExtra (uint16_t extra)
 

Private Types

typedef std::add_lvalue_reference< T >::type reference
 

Private Attributes

PicoSpinLock< uintptr_t > data_
 

Detailed Description

template<class T>
class folly::PackedSyncPtr< T >

Definition at line 63 of file PackedSyncPtr.h.

Member Typedef Documentation

template<class T>
typedef std::add_lvalue_reference<T>::type folly::PackedSyncPtr< T >::reference
private

Definition at line 67 of file PackedSyncPtr.h.

Member Function Documentation

template<class T>
void folly::PackedSyncPtr< T >::init ( T initialPtr = nullptr,
uint16_t  initialExtra = 0 
)
inline

Definition at line 77 of file PackedSyncPtr.h.

References folly::PackedSyncPtr< T >::data_, folly::PicoSpinLock< IntType, Bit >::init(), and folly::PackedSyncPtr< T >::setExtra().

Referenced by folly::atomic_shared_ptr< T, Atom, CountedDetail >::get_newptr(), folly::atomic_shared_ptr< T, Atom, CountedDetail >::init(), SyncVec< T >::SyncVec(), and TEST().

77  {
78  auto intPtr = reinterpret_cast<uintptr_t>(initialPtr);
79  CHECK(!(intPtr >> 48));
80  data_.init(intPtr);
81  setExtra(initialExtra);
82  }
void setExtra(uint16_t extra)
void init(IntType initialValue=0)
Definition: PicoSpinLock.h:96
PicoSpinLock< uintptr_t > data_
template<class T>
void folly::PackedSyncPtr< T >::lock ( ) const
inline

Definition at line 118 of file PackedSyncPtr.h.

References folly::PackedSyncPtr< T >::data_, and folly::PicoSpinLock< IntType, Bit >::lock().

Referenced by SyncVec< T >::lock(), and TEST().

118  {
119  data_.lock();
120  }
PicoSpinLock< uintptr_t > data_
void lock() const
Definition: PicoSpinLock.h:229
template<class T>
reference folly::PackedSyncPtr< T >::operator* ( ) const
inline

Definition at line 109 of file PackedSyncPtr.h.

109  {
110  return *get();
111  }
template<class T>
T* folly::PackedSyncPtr< T >::operator-> ( ) const
inline

Definition at line 106 of file PackedSyncPtr.h.

106  {
107  return get();
108  }
template<class T>
reference folly::PackedSyncPtr< T >::operator[] ( std::ptrdiff_t  i) const
inline

Definition at line 112 of file PackedSyncPtr.h.

112  {
113  return get()[i];
114  }
template<class T>
void folly::PackedSyncPtr< T >::set ( T t)
inline

Definition at line 89 of file PackedSyncPtr.h.

References folly::PackedSyncPtr< T >::data_, folly::PackedSyncPtr< T >::extra(), folly::PicoSpinLock< IntType, Bit >::setData(), and folly::pushmi::detail::t.

Referenced by SyncVec< T >::push_back(), and TEST().

89  {
90  auto intPtr = reinterpret_cast<uintptr_t>(t);
91  auto shiftedExtra = uintptr_t(extra()) << 48;
92  CHECK(!(intPtr >> 48));
93  data_.setData(intPtr | shiftedExtra);
94  }
uint16_t extra() const
PicoSpinLock< uintptr_t > data_
void setData(IntType w)
Definition: PicoSpinLock.h:124
template<class T>
void folly::PackedSyncPtr< T >::setExtra ( uint16_t  extra)
inline

Definition at line 143 of file PackedSyncPtr.h.

References folly::PackedSyncPtr< T >::data_, folly::PicoSpinLock< IntType, Bit >::getData(), ptr, and folly::PicoSpinLock< IntType, Bit >::setData().

Referenced by folly::PackedSyncPtr< T >::init(), SyncVec< T >::push_back(), folly::atomic_shared_ptr< T, Atom, CountedDetail >::takeOwnedBase(), and TEST().

143  {
144  CHECK(!(extra & 0x8000));
145  auto ptr = data_.getData() & (-1ull >> 16);
146  data_.setData((uintptr_t(extra) << 48) | ptr);
147  }
void * ptr
uint16_t extra() const
IntType getData() const
Definition: PicoSpinLock.h:111
PicoSpinLock< uintptr_t > data_
void setData(IntType w)
Definition: PicoSpinLock.h:124
template<class T>
bool folly::PackedSyncPtr< T >::try_lock ( ) const
inline

Definition at line 124 of file PackedSyncPtr.h.

References folly::PackedSyncPtr< T >::data_, and folly::PicoSpinLock< IntType, Bit >::try_lock().

124  {
125  return data_.try_lock();
126  }
PicoSpinLock< uintptr_t > data_
bool try_lock() const
Definition: PicoSpinLock.h:136
template<class T>
void folly::PackedSyncPtr< T >::unlock ( ) const
inline

Definition at line 121 of file PackedSyncPtr.h.

References folly::PackedSyncPtr< T >::data_, and folly::PicoSpinLock< IntType, Bit >::unlock().

Referenced by TEST(), and SyncVec< T >::unlock().

121  {
122  data_.unlock();
123  }
PicoSpinLock< uintptr_t > data_
void unlock() const
Definition: PicoSpinLock.h:240

Member Data Documentation


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