diff --git a/include/callback.h b/include/callback.h new file mode 100644 index 0000000..2a6e98c --- /dev/null +++ b/include/callback.h @@ -0,0 +1,39 @@ +#ifndef CALLBACK_H +#define CALLBACK_H + +#include +#include + +namespace smo { + +// Forward declaration +class AsyncContinuation; + +/** + * @brief Callback class that wraps a function and its caller continuation + * + * 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. + */ +template +class Callback +{ +public: + /** + * @brief Constructor + * @param caller The caller's continuation + * @param cb The callback function to invoke + */ + Callback(std::shared_ptr caller, std::function cb) + : callerContinuation(std::move(caller)), callback(std::move(cb)) + {} + +public: + std::shared_ptr callerContinuation; + std::function callback; +}; + +} // namespace smo + +#endif // CALLBACK_H