Commit 2d0d7cb6 authored by Lewis Baker's avatar Lewis Baker Committed by Facebook GitHub Bot

Simplify logic for popping the current AsyncStackFrame

Summary:
Rather than conditionally calling either popAsyncStackFrameCallee()
or deactivateAsyncStackFrame() depending on whether there is a
parent frame, we now extend popAsyncStackFrameCallee() to handle
the null parent case.

Reviewed By: andriigrynenko

Differential Revision: D24554471

fbshipit-source-id: 7f7ce64da63db1fa726d9fb23669fe49d03c2d6c
parent 11de2a3f
......@@ -56,11 +56,12 @@ inline void pushAsyncStackFrameCallerCallee(
inline void popAsyncStackFrameCallee(
folly::AsyncStackFrame& calleeFrame) noexcept {
checkAsyncStackFrameIsActive(calleeFrame);
assert(calleeFrame.parentFrame != nullptr);
auto& callerFrame = *calleeFrame.parentFrame;
auto& stackRoot = *calleeFrame.stackRoot;
callerFrame.stackRoot = &stackRoot;
stackRoot.topFrame.store(&callerFrame, std::memory_order_release);
auto* callerFrame = calleeFrame.parentFrame;
auto* stackRoot = calleeFrame.stackRoot;
if (callerFrame != nullptr) {
callerFrame->stackRoot = stackRoot;
}
stackRoot->topFrame.store(callerFrame, std::memory_order_release);
// Clearing out non-top-frame's stackRoot is not strictly necessary
// but it may help with debugging.
......
......@@ -241,8 +241,9 @@ void pushAsyncStackFrameCallerCallee(
// you are about to call/resume the caller. e.g. performing a symmetric
// transfer to the calling coroutine in final_suspend().
//
// Assumes that there is actually a parent frame. If there is no parent
// frame then use deactivateAsyncStackFrame() instead.
// If calleeFrame.getParentFrame() is null then this method is equivalent
// to deactivateAsyncStackFrame(), leaving no active AsyncStackFrame on
// the current AsyncStackRoot.
void popAsyncStackFrameCallee(folly::AsyncStackFrame& calleeFrame) noexcept;
// Get a pointer to a special frame that can be used as the root-frame
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment