{
debugs(33, 6, this);
- if (callback_) // job-ending emergencies like noteAbort() or callException()
+ if (callback_) // job-ending emergencies like handleStopRequest() or callException()
callBack(Http::scInternalServerError);
if (context_) {
virtual void callEnd(); ///< called right after the called job method
/// called when the job throws during an async call
virtual void callException(const std::exception &e);
- void noteAbort() { mustStop("externally aborted"); }
- /// writes the job text representation
- std::ostream &print(std::ostream &os) const { return os << id; }
+
+ /// process external request to terminate now (i.e. during this async call)
+ void handleStopRequest() { mustStop("externally aborted"); }
+
+ const InstanceId<AsyncJob> id; ///< job identifier
protected:
// external destruction prohibited to ensure swanSong() is called
const char *stopReason; ///< reason for forcing done() to be true
const char *typeName; ///< kid (leaf) class name, for debugging
AsyncCall::Pointer inCall; ///< the asynchronous call being handled, if any
- const InstanceId<AsyncJob> id; ///< job identifier
};
-inline
-std::ostream &operator <<(std::ostream &os, const AsyncJob &job)
-{
- return job.print(os);
-}
-
#endif /* SQUID_ASYNC_JOB_H */
{
if (callback_) {
callback_->cancel(reason);
+
// Instead of AsyncJob, the class parameter could be Job. That would
// avoid runtime child-to-parent CbcPointer conversion overheads, but
// complicate support for Jobs with virtual AsyncJob bases (GCC error:
// "pointer to member conversion via virtual base AsyncJob") and also
- // cache-log "Job::noteAbort()" which uses a non-existent class name.
- CallJobHere(callback_->debugSection, callback_->debugLevel, job_, AsyncJob, noteAbort);
+ // cache-log "Job::handleStopRequest()" with a non-existent class name.
+ CallJobHere(callback_->debugSection, callback_->debugLevel, job_, AsyncJob, handleStopRequest);
+
clear();
}
}
if (callback_)
os << callback_->id << "<-";
if (const auto rawJob = job_.get())
- os << *rawJob; // TODO: make AsyncJob::id public
+ os << rawJob->id;
else
os << job_; // raw pointer of a gone job may still be useful for triage
return os;
if (requestWritten && tunnelEstablished) {
sendSuccess();
} else {
- // job-ending emergencies like noteAbort() or callException()
+ // job-ending emergencies like handleStopRequest() or callException()
bailWith(new ErrorState(ERR_GATEWAY_FAILURE, Http::scInternalServerError, request.getRaw(), al));
}
assert(!callback);