Subscription.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_SRC_BASE_SUBSCRIPTION_H
10 #define SQUID_SRC_BASE_SUBSCRIPTION_H
11 
12 #include "base/AsyncCall.h"
13 
26 {
27 public:
29 
34  virtual AsyncCall::Pointer callback() const = 0;
35 };
36 
47 template<class Call_>
49 {
50 public:
52  explicit CallSubscription(const RefCount<Call_> &aCall) : call(aCall) { assert(aCall != nullptr); }
53  AsyncCall::Pointer callback() const override
54  {
55  const AsyncCall::Pointer cb = new Call_(*call);
56  if (!cb->codeContext || CodeContext::Current())
58  return cb;
59  }
60 
61 private:
63 };
64 
65 #endif /* SQUID_SRC_BASE_SUBSCRIPTION_H */
66 
CodeContext::Pointer codeContext
what the callee is expected to work on
Definition: AsyncCall.h:74
virtual AsyncCall::Pointer callback() const =0
RefCount< Subscription > Pointer
Definition: Subscription.h:28
#define assert(EX)
Definition: assert.h:17
CallSubscription(const RefCount< Call_ > &aCall)
Must be passed an object. nil pointers are not permitted.
Definition: Subscription.h:52
const RefCount< Call_ > call
gets copied to create callback calls
Definition: Subscription.h:62
AsyncCall::Pointer callback() const override
Definition: Subscription.h:53
static const Pointer & Current()
Definition: CodeContext.cc:33

 

Introduction

Documentation

Support

Miscellaneous