Async: add sh_ptr<ContinuationChainLink> to Callback<>

This change enables us to finally implement the tracing of
continuations backward from the point of acquisition for deadlock
debugging.
This commit is contained in:
2025-09-27 18:30:09 -04:00
parent 2212aec080
commit 782bcd4567
26 changed files with 384 additions and 269 deletions
+6 -13
View File
@@ -7,7 +7,7 @@
namespace smo {
// Forward declaration
class AsyncContinuation;
class AsynchronousContinuationChainLink;
/**
* @brief Callback class that wraps a function and its caller continuation
@@ -15,23 +15,16 @@ class AsyncContinuation;
* This class provides a way to pass both a callback function and the
* caller's continuation in a single object, enabling deadlock detection
* by walking the chain of continuations.
*
* Usage: Callback<CbFnT>{context, std::bind(...)}
*/
template<typename CbFnT>
class Callback
{
public:
/**
* @brief Constructor
* @param caller The caller's continuation
* @param cb The callback function to invoke
*/
Callback(std::shared_ptr<AsyncContinuation> caller, std::function<CbFnT> cb)
: callerContinuation(std::move(caller)), callback(std::move(cb))
{}
public:
std::shared_ptr<AsyncContinuation> callerContinuation;
std::function<CbFnT> callback;
// Aggregate initialization allows: Callback<CbFnT>{context, std::bind(...)}
std::shared_ptr<AsynchronousContinuationChainLink> callerContinuation;
CbFnT callbackFn;
};
} // namespace smo