/* * Copyright (C) 1996-2024 The Squid Software Foundation and contributors * * Squid software is distributed under GPLv2+ license and includes * contributions from numerous individuals and organizations. * Please see the COPYING and CONTRIBUTORS files for details. */ #ifndef SQUID_SRC_BASE_ASYNCCBDATACALLS_H #define SQUID_SRC_BASE_ASYNCCBDATACALLS_H #include "base/AsyncCall.h" #include "base/CbcPointer.h" // dialer to run cbdata callback functions as Async Calls // to ease the transition of these cbdata objects to full Jobs template class UnaryCbdataDialer : public CallDialer { public: typedef void Handler(Argument1 *); UnaryCbdataDialer(Handler *aHandler, Argument1 *aArg) : arg1(aArg), handler(aHandler) {} virtual bool canDial(AsyncCall &) { return arg1.valid(); } void dial(AsyncCall &) { handler(arg1.get()); } void print(std::ostream &os) const override { os << '(' << arg1 << ')'; } public: CbcPointer arg1; Handler *handler; }; // helper function to simplify Dialer creation. template UnaryCbdataDialer cbdataDialer(typename UnaryCbdataDialer::Handler *handler, Argument1 *arg1) { return UnaryCbdataDialer(handler, arg1); } #endif /* SQUID_SRC_BASE_ASYNCCBDATACALLS_H */