proxygen
folly::fibers::FiberImpl Class Reference

#include <BoostContextCompatibility.h>

Public Member Functions

 FiberImpl (folly::Function< void()> func, unsigned char *stackLimit, size_t stackSize)
 
void activate ()
 
void deactivate ()
 

Private Types

using FiberContext = boost::ctx::fcontext_t
 
using MainContext = boost::ctx::fcontext_t
 

Static Private Member Functions

static void fiberFunc (intptr_t arg)
 

Private Attributes

folly::Function< void()> func_
 
FiberContext fiberContext_
 
MainContext mainContext_
 

Detailed Description

Definition at line 44 of file BoostContextCompatibility.h.

Member Typedef Documentation

using folly::fibers::FiberImpl::FiberContext = boost::ctx::fcontext_t
private

Definition at line 52 of file BoostContextCompatibility.h.

using folly::fibers::FiberImpl::MainContext = boost::ctx::fcontext_t
private

Definition at line 62 of file BoostContextCompatibility.h.

Constructor & Destructor Documentation

folly::fibers::FiberImpl::FiberImpl ( folly::Function< void()>  func,
unsigned char *  stackLimit,
size_t  stackSize 
)
inline

Definition at line 66 of file BoostContextCompatibility.h.

References fiberContext_, and fiberFunc().

70  : func_(std::move(func)) {
71  auto stackBase = stackLimit + stackSize;
72 #if BOOST_VERSION >= 106100
73  stackBase_ = stackBase;
75  boost::context::detail::make_fcontext(stackBase, stackSize, &fiberFunc);
76 #elif BOOST_VERSION >= 105200
78  boost::context::make_fcontext(stackBase, stackSize, &fiberFunc);
79 #else
80  fiberContext_.fc_stack.limit = stackLimit;
81  fiberContext_.fc_stack.base = stackBase;
82  make_fcontext(&fiberContext_, &fiberFunc);
83 #endif
84  }
folly::Function< void()> func_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static void fiberFunc(intptr_t arg)

Member Function Documentation

void folly::fibers::FiberImpl::activate ( )
inline

Definition at line 86 of file BoostContextCompatibility.h.

References context, fiberContext_, and mainContext_.

Referenced by folly::fibers::FiberManager::activateFiber().

86  {
87 #if BOOST_VERSION >= 106100
88  auto transfer = boost::context::detail::jump_fcontext(fiberContext_, this);
89  fiberContext_ = transfer.fctx;
90  auto context = reinterpret_cast<intptr_t>(transfer.data);
91 #elif BOOST_VERSION >= 105200
92  auto context = boost::context::jump_fcontext(
93  &mainContext_, fiberContext_, reinterpret_cast<intptr_t>(this));
94 #else
95  auto context = jump_fcontext(
96  &mainContext_, &fiberContext_, reinterpret_cast<intptr_t>(this));
97 #endif
98  DCHECK_EQ(0, context);
99  }
context
Definition: CMakeCache.txt:563
void folly::fibers::FiberImpl::deactivate ( )
inline

Definition at line 101 of file BoostContextCompatibility.h.

References context, fiberContext_, fiberFunc(), folly::kIsArchAmd64, folly::kIsLinux, and mainContext_.

Referenced by folly::fibers::FiberManager::deactivateFiber().

101  {
102 #if BOOST_VERSION >= 106100
103  auto transfer =
104  boost::context::detail::jump_fcontext(mainContext_, nullptr);
105  mainContext_ = transfer.fctx;
106  fixStackUnwinding();
107  auto context = reinterpret_cast<intptr_t>(transfer.data);
108 #elif BOOST_VERSION >= 105600
109  auto context =
110  boost::context::jump_fcontext(&fiberContext_, mainContext_, 0);
111 #elif BOOST_VERSION >= 105200
112  auto context =
113  boost::context::jump_fcontext(fiberContext_, &mainContext_, 0);
114 #else
115  auto context = jump_fcontext(&fiberContext_, &mainContext_, 0);
116 #endif
117  DCHECK_EQ(this, reinterpret_cast<FiberImpl*>(context));
118  }
context
Definition: CMakeCache.txt:563
static void folly::fibers::FiberImpl::fiberFunc ( intptr_t  arg)
inlinestaticprivate

Definition at line 142 of file BoostContextCompatibility.h.

References func_.

Referenced by deactivate(), and FiberImpl().

142  {
143  auto fiberImpl = reinterpret_cast<FiberImpl*>(arg);
144  fiberImpl->func_();
145  }
FiberImpl(folly::Function< void()> func, unsigned char *stackLimit, size_t stackSize)

Member Data Documentation

FiberContext folly::fibers::FiberImpl::fiberContext_
private

Definition at line 149 of file BoostContextCompatibility.h.

Referenced by activate(), deactivate(), and FiberImpl().

folly::Function<void()> folly::fibers::FiberImpl::func_
private

Definition at line 148 of file BoostContextCompatibility.h.

Referenced by fiberFunc().

MainContext folly::fibers::FiberImpl::mainContext_
private

Definition at line 150 of file BoostContextCompatibility.h.

Referenced by activate(), and deactivate().


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