18 #include <boost/version.hpp> 19 #if BOOST_VERSION >= 106100 20 #include <boost/context/detail/fcontext.hpp> 22 #include <boost/context/fcontext.hpp> 24 #include <glog/logging.h> 45 #if BOOST_VERSION >= 106100 47 #elif BOOST_VERSION >= 105600 49 #elif BOOST_VERSION >= 105200 55 #if BOOST_VERSION >= 106100 56 using MainContext = boost::context::detail::fcontext_t;
57 #elif BOOST_VERSION >= 105600 59 #elif BOOST_VERSION >= 105200 68 unsigned char* stackLimit,
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);
87 #if BOOST_VERSION >= 106100 88 auto transfer = boost::context::detail::jump_fcontext(
fiberContext_,
this);
90 auto context =
reinterpret_cast<intptr_t
>(transfer.data);
91 #elif BOOST_VERSION >= 105200 92 auto context = boost::context::jump_fcontext(
102 #if BOOST_VERSION >= 106100 104 boost::context::detail::jump_fcontext(
mainContext_,
nullptr);
107 auto context =
reinterpret_cast<intptr_t
>(transfer.data);
108 #elif BOOST_VERSION >= 105600 111 #elif BOOST_VERSION >= 105200 117 DCHECK_EQ(
this, reinterpret_cast<FiberImpl*>(
context));
121 #if BOOST_VERSION >= 106100 122 static void fiberFunc(boost::context::detail::transfer_t transfer) {
123 auto fiberImpl =
reinterpret_cast<FiberImpl*
>(transfer.data);
125 fiberImpl->fixStackUnwinding();
129 void fixStackUnwinding() {
133 auto stackBase =
reinterpret_cast<void**
>(stackBase_);
134 auto mainContext =
reinterpret_cast<void**
>(
mainContext_);
135 stackBase[-2] = mainContext[6];
136 stackBase[-1] = mainContext[7];
140 unsigned char* stackBase_;
143 auto fiberImpl =
reinterpret_cast<FiberImpl*
>(arg);
folly::Function< void()> func_
constexpr detail::Map< Move > move
—— Concurrent Priority Queue Implementation ——
boost::ctx::fcontext_t FiberContext
FiberContext fiberContext_
FiberImpl(folly::Function< void()> func, unsigned char *stackLimit, size_t stackSize)
constexpr bool kIsArchAmd64
static void fiberFunc(intptr_t arg)
boost::ctx::fcontext_t MainContext