]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
fixup: Moved JobWait classes to their own files
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 15 Jul 2021 21:58:50 +0000 (17:58 -0400)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 16 Jul 2021 17:33:09 +0000 (13:33 -0400)
Technically, there may exist some code that uses JobWait but does not
make any JobCalls itself. And the new classes are big/interesting
enough to deserve their own files anyway.

13 files changed:
src/FwdState.h
src/PeerPoolMgr.h
src/adaptation/icap/Xaction.cc
src/adaptation/icap/Xaction.h
src/base/AsyncJobCalls.h
src/base/JobWait.cc [moved from src/base/AsyncJobCalls.cc with 98% similarity]
src/base/JobWait.h [new file with mode: 0644]
src/base/Makefile.am
src/comm/Connection.cc
src/log/TcpLogger.h
src/security/PeerConnector.h
src/servers/FtpServer.h
src/tunnel.cc

index c8e03500ec2be378962c6a0a8a9352acd6f71251..b501ad66f6973a3763121214ce806ba4b6cfbed5 100644 (file)
@@ -10,6 +10,7 @@
 #define SQUID_FORWARD_H
 
 #include "base/forward.h"
+#include "base/JobWait.h"
 #include "base/RefCount.h"
 #include "clients/forward.h"
 #include "comm.h"
index 4dd7e4bc5d9e2662e1b0cd2ecd2912053b9d8eba..ae07c1fd1c9533fe0287f84e41516b2c03817b05 100644 (file)
@@ -10,7 +10,7 @@
 #define SQUID_PEERPOOLMGR_H
 
 #include "base/AsyncJob.h"
-#include "base/forward.h"
+#include "base/JobWait.h"
 #include "comm/forward.h"
 #include "security/forward.h"
 
index cc9edffa9087b6ee2960dda0fe4d6e6434d49ccf..6a27bb683fe0b5e53b61d02388f6cf02fb1b63d9 100644 (file)
@@ -13,7 +13,7 @@
 #include "adaptation/icap/Config.h"
 #include "adaptation/icap/Launcher.h"
 #include "adaptation/icap/Xaction.h"
-#include "base/AsyncJobCalls.h"
+#include "base/JobWait.h"
 #include "base/TextException.h"
 #include "comm.h"
 #include "comm/Connection.h"
index 9956d9ac1ee76458d8dfd66b4b0962a9a43937b8..ad78e4e75444fa3c77dbeb4d06243df1cb79d751 100644 (file)
@@ -12,7 +12,7 @@
 #include "AccessLogEntry.h"
 #include "adaptation/icap/ServiceRep.h"
 #include "adaptation/Initiate.h"
-#include "base/forward.h"
+#include "base/JobWait.h"
 #include "comm/ConnOpener.h"
 #include "HttpReply.h"
 #include "ipcache.h"
index ec9a968ae7ad0491c386af697e8b4a43f40186d6..811ac7414c960c979bffaf19f286d2760ad1174f 100644 (file)
@@ -13,8 +13,6 @@
 #include "base/CbcPointer.h"
 #include "Debug.h"
 
-#include <iosfwd>
-
 /**
  \ingroup AsyncJobAPI
  * This is a base class for all job call dialers. It does all the job
@@ -184,78 +182,5 @@ JobDialer<Job>::dial(AsyncCall &call)
     job->callEnd(); // may delete job
 }
 
-/// Manages waiting for an AsyncJob callback. Use type-safe JobWait instead.
-/// This base class does not contain code specific to the actual Job type.
-class JobWaitBase
-{
-public:
-    JobWaitBase();
-    ~JobWaitBase();
-
-    /// no copying of any kind: each waiting context needs a dedicated AsyncCall
-    JobWaitBase(JobWaitBase &&) = delete;
-
-    explicit operator bool() const { return waiting(); }
-
-    /// whether we are currently waiting for the job to call us back
-    /// the job itself may be gone even if this returns true
-    bool waiting() const { return bool(callback_); }
-
-    /// ends wait (after receiving the call back)
-    /// forgets the job which is likely to be gone by now
-    void finish();
-
-    /// aborts wait (if any) before receiving the call back
-    /// does nothing if we are not waiting
-    void cancel(const char *reason);
-
-    /// summarizes what we are waiting for (for debugging)
-    void print(std::ostream &) const;
-
-protected:
-    /// starts waiting for the given job to call the given callback
-    void start_(AsyncJob::Pointer, AsyncCall::Pointer);
-
-private:
-    /// the common part of finish() and cancel()
-    void clear() { job_.clear(); callback_ = nullptr; }
-
-    /// the job that we are waiting to call us back (or nil)
-    AsyncJob::Pointer job_;
-
-    /// the call we are waiting for the job_ to make (or nil)
-    AsyncCall::Pointer callback_;
-};
-
-/// Manages waiting for an AsyncJob callback.
-/// Completes JobWaitBase by providing Job type-specific members.
-template <class Job>
-class JobWait: public JobWaitBase
-{
-public:
-    typedef CbcPointer<Job> JobPointer;
-
-    /// starts waiting for the given job to call the given callback
-    void start(const JobPointer &aJob, const AsyncCall::Pointer &aCallback) {
-        start_(aJob, aCallback);
-        typedJob_ = aJob;
-    }
-
-    /// \returns a cbdata pointer to the job we are waiting for (or nil)
-    /// the returned pointer may be falsy, even if we are still waiting()
-    JobPointer job() const { return waiting() ? typedJob_ : nullptr; }
-
-private:
-    /// nearly duplicates JobWaitBase::typedJob_ but exposes the actual job type
-    JobPointer typedJob_;
-};
-
-inline
-std::ostream &operator <<(std::ostream &os, const JobWaitBase &wait)
-{
-    wait.print(os);
-    return os;
-}
-
 #endif /* SQUID_ASYNCJOBCALLS_H */
 
similarity index 98%
rename from src/base/AsyncJobCalls.cc
rename to src/base/JobWait.cc
index 2e88a97521dde957fb06e1b9186cf26a2dee364a..cc6b0c5d5f667ad2732a18738b275ccad4c771e2 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "squid.h"
 #include "base/AsyncJobCalls.h"
-#include "Debug.h"
+#include "base/JobWait.h"
 
 #include <cassert>
 #include <iostream>
diff --git a/src/base/JobWait.h b/src/base/JobWait.h
new file mode 100644 (file)
index 0000000..fff9acc
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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_BASE_JOBWAIT_H
+#define SQUID_BASE_JOBWAIT_H
+
+#include "base/AsyncJob.h"
+#include "base/CbcPointer.h"
+
+#include <iosfwd>
+
+/// Manages waiting for an AsyncJob callback. Use type-safe JobWait instead.
+/// This base class does not contain code specific to the actual Job type.
+class JobWaitBase
+{
+public:
+    JobWaitBase();
+    ~JobWaitBase();
+
+    /// no copying of any kind: each waiting context needs a dedicated AsyncCall
+    JobWaitBase(JobWaitBase &&) = delete;
+
+    explicit operator bool() const { return waiting(); }
+
+    /// whether we are currently waiting for the job to call us back
+    /// the job itself may be gone even if this returns true
+    bool waiting() const { return bool(callback_); }
+
+    /// ends wait (after receiving the call back)
+    /// forgets the job which is likely to be gone by now
+    void finish();
+
+    /// aborts wait (if any) before receiving the call back
+    /// does nothing if we are not waiting
+    void cancel(const char *reason);
+
+    /// summarizes what we are waiting for (for debugging)
+    void print(std::ostream &) const;
+
+protected:
+    /// starts waiting for the given job to call the given callback
+    void start_(AsyncJob::Pointer, AsyncCall::Pointer);
+
+private:
+    /// the common part of finish() and cancel()
+    void clear() { job_.clear(); callback_ = nullptr; }
+
+    /// the job that we are waiting to call us back (or nil)
+    AsyncJob::Pointer job_;
+
+    /// the call we are waiting for the job_ to make (or nil)
+    AsyncCall::Pointer callback_;
+};
+
+/// Manages waiting for an AsyncJob callback.
+/// Completes JobWaitBase by providing Job type-specific members.
+template <class Job>
+class JobWait: public JobWaitBase
+{
+public:
+    typedef CbcPointer<Job> JobPointer;
+
+    /// starts waiting for the given job to call the given callback
+    void start(const JobPointer &aJob, const AsyncCall::Pointer &aCallback) {
+        start_(aJob, aCallback);
+        typedJob_ = aJob;
+    }
+
+    /// \returns a cbdata pointer to the job we are waiting for (or nil)
+    /// the returned pointer may be falsy, even if we are still waiting()
+    JobPointer job() const { return waiting() ? typedJob_ : nullptr; }
+
+private:
+    /// nearly duplicates JobWaitBase::typedJob_ but exposes the actual job type
+    JobPointer typedJob_;
+};
+
+inline
+std::ostream &operator <<(std::ostream &os, const JobWaitBase &wait)
+{
+    wait.print(os);
+    return os;
+}
+
+#endif /* SQUID_BASE_JOBWAIT_H */
+
index f1934d6b34b189aab4800906b0fc74c1b96d35ed..30e50257d741b120954d04aa0793646d87d8d06e 100644 (file)
@@ -18,7 +18,6 @@ libbase_la_SOURCES = \
        AsyncCbdataCalls.h \
        AsyncJob.cc \
        AsyncJob.h \
-       AsyncJobCalls.cc \
        AsyncJobCalls.h \
        ByteCounter.h \
        CbDataList.h \
@@ -36,6 +35,8 @@ libbase_la_SOURCES = \
        Here.h \
        InstanceId.cc \
        InstanceId.h \
+       JobWait.cc \
+       JobWait.h \
        Lock.h \
        LookupTable.h \
        Optional.h \
index 3217d0b71e4f73a2a71e7d8119ba0a07ddb0c2a1..1f1c706513bcf5429777744556e66eaae0668421 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "squid.h"
+#include "base/JobWait.h"
 #include "CachePeer.h"
 #include "cbdata.h"
 #include "comm.h"
index 7a316729bd751e6ea12c600a57ad53c9a99df37b..b1ff6e16e5170c4ed0b9b948a0002cc4f09ac44b 100644 (file)
@@ -10,7 +10,7 @@
 #define _SQUID_SRC_LOG_TCPLOGGER_H
 
 #include "base/AsyncJob.h"
-#include "base/forward.h"
+#include "base/JobWait.h"
 #include "comm/forward.h"
 #include "ip/Address.h"
 
index cb6cb0f64227a51da653cf4b1c11b988bce6764b..4c81d553962cd1b11b761a40b86957e6b9a8e596 100644 (file)
@@ -12,7 +12,7 @@
 #include "acl/Acl.h"
 #include "base/AsyncCbdataCalls.h"
 #include "base/AsyncJob.h"
-#include "base/forward.h"
+#include "base/JobWait.h"
 #include "CommCalls.h"
 #include "http/forward.h"
 #include "security/EncryptorAnswer.h"
index fc73accbc4a48eddc911da30dccc73b4cf4cb52a..10f9d4ff9ddac0c0876196a4262fbc811bbc9703 100644 (file)
@@ -11,7 +11,7 @@
 #ifndef SQUID_SERVERS_FTP_SERVER_H
 #define SQUID_SERVERS_FTP_SERVER_H
 
-#include "base/forward.h"
+#include "base/JobWait.h"
 #include "base/Lock.h"
 #include "client_side.h"
 #include "comm/forward.h"
index da7c1b8c9117a2d5ab4237bcb53677909576e55e..d1e3e402fbdb150bf1937ce92810c92c73e46947 100644 (file)
@@ -11,6 +11,7 @@
 #include "squid.h"
 #include "acl/FilledChecklist.h"
 #include "base/CbcPointer.h"
+#include "base/JobWait.h"
 #include "CachePeer.h"
 #include "cbdata.h"
 #include "client_side.h"