folly::AsyncStackRoot

A stack-root represents the context of an event loop that is running some asynchronous work. The current async operation that is being executed by the event loop (if any) is pointed to by the 'topFrame'.

Synopsis

Declared in <folly/tracing/AsyncStack.h>

struct AsyncStackRoot;

Description

If the current event loop is running nested inside some other event loop context then the 'nextRoot' points to the AsyncStackRoot context for the next event loop up the stack on the current thread.

The 'stackFramePtr' holds a pointer to the normal stack-frame that is currently executing this event loop. This allows reconciliation of the parts between a normal stack-trace and the start of the async-stack trace.

The current thread's top-most context (the head of the linked list of contexts) is obtained by calling getCurrentAsyncStackRoot().

Member Functions

NameDescription
AsyncStackRoot [constructor]Constructors
~AsyncStackRoot [destructor]Destroys the stack root.
operator= Assignment operators
getNextRoot Returns the next event loop context lower on the current thread's stack.
getReturnAddress Returns the return address recorded for this stack root.
getStackFramePointer Returns the stack-frame pointer recorded for this stack root.
getTopFrame Returns the currently-active frame for this stack root.
setNextRoot Sets the next event loop context lower on the current thread's stack.
setStackFrameContext Initialises this stack root with information about the context in which the stack-root was declared. This records information about where the async-stack-trace should be spliced into the normal stack-trace.
setTopFrame Sets the top-frame to be 'frame' and also updates the cached 'frame.stackRoot' to be 'this'.

Friends

NameDescription
folly::popAsyncStackFrameCalleePop the 'callee' frame off the stack, restoring the parent frame as the current frame.
folly::checkAsyncStackFrameIsActivePerform some consistency checks on the specified AsyncStackFrame, assuming that it is the currently active AsyncStackFrame.
folly::pushAsyncStackFrameCallerCalleePush the 'callee' frame onto the current thread's async stack, deactivating the 'caller' frame and setting up the 'caller' to be the parent-frame of the 'callee'.
folly::deactivateAsyncStackFrameDeactivate the specified AsyncStackFrame, clearing the current 'topFrame'.
folly::activateAsyncStackFrameActivate the specified AsyncStackFrame on the specified AsyncStackRoot, setting it as the current 'topFrame'.

Non-Member Functions

NameDescription
exchangeCurrentAsyncStackRootExchange the current thread's active AsyncStackRoot with the specified AsyncStackRoot pointer, returning the old AsyncStackRoot pointer.
getCurrentAsyncStackRootGet access to the current thread's top-most AsyncStackRoot.
tryGetCurrentAsyncStackRootGet access to the current thread's top-most AsyncStackRoot.