#define SQUID_FORWARD_H
#include "base/forward.h"
+#include "base/JobWait.h"
#include "base/RefCount.h"
#include "clients/forward.h"
#include "comm.h"
#define SQUID_PEERPOOLMGR_H
#include "base/AsyncJob.h"
-#include "base/forward.h"
+#include "base/JobWait.h"
#include "comm/forward.h"
#include "security/forward.h"
#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"
#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"
#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
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 */
#include "squid.h"
#include "base/AsyncJobCalls.h"
-#include "Debug.h"
+#include "base/JobWait.h"
#include <cassert>
#include <iostream>
--- /dev/null
+/*
+ * 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 */
+
AsyncCbdataCalls.h \
AsyncJob.cc \
AsyncJob.h \
- AsyncJobCalls.cc \
AsyncJobCalls.h \
ByteCounter.h \
CbDataList.h \
Here.h \
InstanceId.cc \
InstanceId.h \
+ JobWait.cc \
+ JobWait.h \
Lock.h \
LookupTable.h \
Optional.h \
*/
#include "squid.h"
+#include "base/JobWait.h"
#include "CachePeer.h"
#include "cbdata.h"
#include "comm.h"
#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"
#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"
#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"
#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"