-
/*
- * $Id$
+ * Copyright (C) 1996-2021 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_ASYNCJOBCALLS_H
#include "base/AsyncJob.h"
#include "base/CbcPointer.h"
+#include "Debug.h"
/**
\ingroup AsyncJobAPI
/// schedule an async job call using a dialer; use CallJobHere macros instead
template <class Dialer>
-bool
+AsyncCall::Pointer
CallJob(int debugSection, int debugLevel, const char *fileName, int fileLine,
const char *callName, const Dialer &dialer)
{
AsyncCall::Pointer call = asyncCall(debugSection, debugLevel, callName, dialer);
- return ScheduleCall(fileName, fileLine, call);
+ ScheduleCall(fileName, fileLine, call);
+ return call;
}
-
#define CallJobHere(debugSection, debugLevel, job, Class, method) \
CallJob((debugSection), (debugLevel), __FILE__, __LINE__, \
(#Class "::" #method), \
(#Class "::" #method), \
JobMemFun((job), &Class::method, (arg1)))
-
/// Convenience macro to create a Dialer-based job callback
#define JobCallback(dbgSection, dbgLevel, Dialer, job, method) \
asyncCall((dbgSection), (dbgLevel), #method, \
Dialer(CbcPointer<Dialer::DestClass>(job), &method))
-
/*
* *MemFunT are member function (i.e., class method) wrappers. They store
* details of a method call in an object so that the call can be delayed
public:
typedef void (Job::*Method)();
explicit NullaryMemFunT(const CbcPointer<Job> &aJob, Method aMethod):
- JobDialer<Job>(aJob), method(aMethod) {}
+ JobDialer<Job>(aJob), method(aMethod) {}
virtual void print(std::ostream &os) const { os << "()"; }
virtual void doDial() { ((&(*this->job))->*method)(); }
};
-template <class Job, class Argument1>
+template <class Job, class Data, class Argument1 = Data>
class UnaryMemFunT: public JobDialer<Job>
{
public:
typedef void (Job::*Method)(Argument1);
explicit UnaryMemFunT(const CbcPointer<Job> &aJob, Method aMethod,
- const Argument1 &anArg1): JobDialer<Job>(aJob),
- method(aMethod), arg1(anArg1) {}
+ const Data &anArg1): JobDialer<Job>(aJob),
+ method(aMethod), arg1(anArg1) {}
virtual void print(std::ostream &os) const { os << '(' << arg1 << ')'; }
public:
Method method;
- Argument1 arg1;
+ Data arg1;
protected:
virtual void doDial() { ((&(*this->job))->*method)(arg1); }
// ... add more as needed
-
// Now we add global templated functions that create the member function
// wrappers above. These are for convenience: it is often easier to
// call a templated function than to create a templated object.
return UnaryMemFunT<C, Argument1>(job, method, arg1);
}
-
// inlined methods
template<class Job>
}
#endif /* SQUID_ASYNCJOBCALLS_H */
+