]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/base/AsyncJobCalls.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / base / AsyncJobCalls.h
index 23434a1a1a0a092c37fa3062f5433d3a19a9d83f..bb7568523eecbdc2e186613b46d0aa216960d772 100644 (file)
@@ -1,6 +1,9 @@
-
 /*
- * $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
@@ -8,6 +11,7 @@
 
 #include "base/AsyncJob.h"
 #include "base/CbcPointer.h"
+#include "Debug.h"
 
 /**
  \ingroup AsyncJobAPI
@@ -42,15 +46,15 @@ private:
 
 /// 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), \
@@ -61,13 +65,11 @@ CallJob(int debugSection, int debugLevel, const char *fileName, int fileLine,
         (#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
@@ -90,7 +92,7 @@ class NullaryMemFunT: public JobDialer<Job>
 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 << "()"; }
 
@@ -101,20 +103,20 @@ protected:
     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); }
@@ -122,7 +124,6 @@ protected:
 
 // ... 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.
@@ -142,7 +143,6 @@ JobMemFun(const CbcPointer<C> &job, typename UnaryMemFunT<C, Argument1>::Method
     return UnaryMemFunT<C, Argument1>(job, method, arg1);
 }
 
-
 // inlined methods
 
 template<class Job>
@@ -183,3 +183,4 @@ JobDialer<Job>::dial(AsyncCall &call)
 }
 
 #endif /* SQUID_ASYNCJOBCALLS_H */
+