proxygen
folly::Executor::KeepAlive< ExecutorT > Class Template Reference

#include <Executor.h>

Public Member Functions

 KeepAlive ()=default
 
 ~KeepAlive ()
 
 KeepAlive (KeepAlive &&other) noexcept
 
template<typename OtherExecutor , typename = typename std::enable_if< std::is_convertible<OtherExecutor*, ExecutorT*>::value>::type>
 KeepAlive (KeepAlive< OtherExecutor > &&other) noexcept
 
KeepAliveoperator= (KeepAlive &&other)
 
template<typename OtherExecutor , typename = typename std::enable_if< std::is_convertible<OtherExecutor*, ExecutorT*>::value>::type>
KeepAliveoperator= (KeepAlive< OtherExecutor > &&other)
 
void reset ()
 
 operator bool () const
 
ExecutorT * get () const
 
ExecutorT & operator* () const
 
ExecutorT * operator-> () const
 
KeepAlive copy () const
 

Private Member Functions

 KeepAlive (ExecutorT *executor, bool dummy)
 

Private Attributes

intptr_t executorAndDummyFlag_ {reinterpret_cast<intptr_t>(nullptr)}
 

Static Private Attributes

static constexpr intptr_t kDummyFlag = 1
 
static constexpr intptr_t kExecutorMask = ~kDummyFlag
 

Friends

class Executor
 
template<typename OtherExecutor >
class KeepAlive
 

Detailed Description

template<typename ExecutorT = Executor>
class folly::Executor::KeepAlive< ExecutorT >

Definition at line 53 of file Executor.h.

Constructor & Destructor Documentation

template<typename ExecutorT = Executor>
folly::Executor::KeepAlive< ExecutorT >::KeepAlive ( )
default
template<typename ExecutorT = Executor>
folly::Executor::KeepAlive< ExecutorT >::~KeepAlive ( )
inline

Definition at line 57 of file Executor.h.

57  {
58  reset();
59  }
template<typename ExecutorT = Executor>
folly::Executor::KeepAlive< ExecutorT >::KeepAlive ( KeepAlive< ExecutorT > &&  other)
inlinenoexcept

Definition at line 61 of file Executor.h.

62  : executorAndDummyFlag_(exchange(other.executorAndDummyFlag_, 0)) {}
intptr_t executorAndDummyFlag_
Definition: Executor.h:134
T exchange(T &obj, U &&new_value)
Definition: Utility.h:120
template<typename ExecutorT = Executor>
template<typename OtherExecutor , typename = typename std::enable_if< std::is_convertible<OtherExecutor*, ExecutorT*>::value>::type>
folly::Executor::KeepAlive< ExecutorT >::KeepAlive ( KeepAlive< OtherExecutor > &&  other)
inlinenoexcept

Definition at line 68 of file Executor.h.

69  : KeepAlive(other.get(), other.executorAndDummyFlag_ & kDummyFlag) {
70  other.executorAndDummyFlag_ = 0;
71  }
static constexpr intptr_t kDummyFlag
Definition: Executor.h:118
template<typename ExecutorT = Executor>
folly::Executor::KeepAlive< ExecutorT >::KeepAlive ( ExecutorT *  executor,
bool  dummy 
)
inlineprivate

Definition at line 125 of file Executor.h.

127  reinterpret_cast<intptr_t>(executor) | (dummy ? kDummyFlag : 0)) {
128  assert(executor);
129  assert(
130  (reinterpret_cast<intptr_t>(executor) & kExecutorMask) ==
131  reinterpret_cast<intptr_t>(executor));
132  }
static constexpr intptr_t kExecutorMask
Definition: Executor.h:119
intptr_t executorAndDummyFlag_
Definition: Executor.h:134
static constexpr intptr_t kDummyFlag
Definition: Executor.h:118
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
void dummy()

Member Function Documentation

template<typename ExecutorT = Executor>
KeepAlive folly::Executor::KeepAlive< ExecutorT >::copy ( ) const
inline

Definition at line 113 of file Executor.h.

Referenced by folly::futures::detail::DeferredExecutor::setExecutor(), and folly::window().

113  {
114  return getKeepAliveToken(get());
115  }
static KeepAlive< ExecutorT > getKeepAliveToken(ExecutorT *executor)
Definition: Executor.h:138
template<typename ExecutorT = Executor>
ExecutorT* folly::Executor::KeepAlive< ExecutorT >::get ( ) const
inline

Definition at line 100 of file Executor.h.

Referenced by folly::TEST().

100  {
101  return reinterpret_cast<ExecutorT*>(
103  }
static constexpr intptr_t kExecutorMask
Definition: Executor.h:119
intptr_t executorAndDummyFlag_
Definition: Executor.h:134
template<typename ExecutorT = Executor>
folly::Executor::KeepAlive< ExecutorT >::operator bool ( ) const
inlineexplicit

Definition at line 96 of file Executor.h.

96  {
97  return executorAndDummyFlag_;
98  }
intptr_t executorAndDummyFlag_
Definition: Executor.h:134
template<typename ExecutorT = Executor>
ExecutorT& folly::Executor::KeepAlive< ExecutorT >::operator* ( ) const
inline

Definition at line 105 of file Executor.h.

105  {
106  return *get();
107  }
template<typename ExecutorT = Executor>
ExecutorT* folly::Executor::KeepAlive< ExecutorT >::operator-> ( ) const
inline

Definition at line 109 of file Executor.h.

109  {
110  return get();
111  }
template<typename ExecutorT = Executor>
KeepAlive& folly::Executor::KeepAlive< ExecutorT >::operator= ( KeepAlive< ExecutorT > &&  other)
inline

Definition at line 73 of file Executor.h.

73  {
74  reset();
75  executorAndDummyFlag_ = exchange(other.executorAndDummyFlag_, 0);
76  return *this;
77  }
intptr_t executorAndDummyFlag_
Definition: Executor.h:134
T exchange(T &obj, U &&new_value)
Definition: Utility.h:120
template<typename ExecutorT = Executor>
template<typename OtherExecutor , typename = typename std::enable_if< std::is_convertible<OtherExecutor*, ExecutorT*>::value>::type>
KeepAlive& folly::Executor::KeepAlive< ExecutorT >::operator= ( KeepAlive< OtherExecutor > &&  other)
inline

Definition at line 83 of file Executor.h.

83  {
84  return *this = KeepAlive(std::move(other));
85  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<typename ExecutorT = Executor>
void folly::Executor::KeepAlive< ExecutorT >::reset ( )
inline

Definition at line 87 of file Executor.h.

Referenced by folly::Executor::KeepAlive< folly::VirtualEventBase >::operator=(), folly::fibers::ExecutorLoopController::runLoop(), and folly::Executor::KeepAlive< folly::VirtualEventBase >::~KeepAlive().

87  {
88  if (Executor* executor = get()) {
90  return;
91  }
92  executor->keepAliveRelease();
93  }
94  }
intptr_t executorAndDummyFlag_
Definition: Executor.h:134
static constexpr intptr_t kDummyFlag
Definition: Executor.h:118
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
T exchange(T &obj, U &&new_value)
Definition: Utility.h:120

Friends And Related Function Documentation

template<typename ExecutorT = Executor>
friend class Executor
friend

Definition at line 121 of file Executor.h.

template<typename ExecutorT = Executor>
template<typename OtherExecutor >
friend class KeepAlive
friend

Definition at line 123 of file Executor.h.

Member Data Documentation

template<typename ExecutorT = Executor>
constexpr intptr_t folly::Executor::KeepAlive< ExecutorT >::kDummyFlag = 1
staticprivate
template<typename ExecutorT = Executor>
constexpr intptr_t folly::Executor::KeepAlive< ExecutorT >::kExecutorMask = ~kDummyFlag
staticprivate

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