]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Implement subscription for AsyncCallT / JobCallback
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 11 Sep 2010 15:26:55 +0000 (03:26 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 11 Sep 2010 15:26:55 +0000 (03:26 +1200)
src/base/AsyncCall.h
src/base/Subscription.h

index a1bdaef0c29c2e8c45a84877e412e4208f666dab..0576b33c4e3fda0a09548e3d6485720f0623cc72 100644 (file)
@@ -121,6 +121,10 @@ public:
                const Dialer &aDialer): AsyncCall(aDebugSection, aDebugLevel, aName),
             dialer(aDialer) {}
 
+    AsyncCallT(const RefCount<AsyncCallT<Dialer> > &o):
+            AsyncCall(o->debugSection, o->debugLevel, o->name),
+            dialer(o->dialer) {}
+
     CallDialer *getDialer() { return &dialer; }
 
 protected:
index 4840260b0a8856efa99bd671547ba279577a61a8..d1d559595e736229576527afd1866640a751da14 100644 (file)
@@ -6,12 +6,13 @@
 
 /**
  * API for classes needing to emit multiple event-driven AsyncCalls.
- * A receiver class uses this API to subscribe interest in the
- * events being handled or watched for by the API child.
  *
- * The API child then uses this to create and emit a call as needed.
+ * The emitter class needs to accept and store a Subscription::Pointer.
+ * The callback() function will spawn AsyncCalls to be filled out and
+ * scheduled wth every event happening.
  */
-class Subscription: public RefCountable {
+class Subscription: public RefCountable
+{
 public:
     typedef RefCount<Subscription> Pointer;
 
@@ -20,13 +21,24 @@ public:
 //    virtual AsyncCall::Pointer callback() const = 0;
 };
 
-/// implements Subscription API using Call's copy constructor
+/**
+ * Implements Subscription API using Call's copy constructor.
+ *
+ * A receiver class allocates one of these templated from the Call type
+ * to be received (usually AsyncCallT) and passes it to the emitter class
+ * which will use it to spawn event calls.
+ *
+ * To be a subscriber the AsyncCall child must implement a copy constructor.
+ */
 template<class Call_>
 class CallSubscription: public Subscription
 {
 public:
-    // cant be const because CommCbFunPtrCallT cant provide a const overload.
+    CallSubscription(const RefCount<Call_> &aCall) : call(aCall) {};
+
+    // cant be const sometimes because CommCbFunPtrCallT cant provide a const overload.
     // CommCbFunPtrCallT lists why. boils down to Comm IO syncWithComm() existence
+    // NP: we still treat it as const though.
     CallSubscription(RefCount<Call_> &aCall) : call(aCall) {};
     virtual AsyncCall::Pointer callback() { return new Call_(call); };
 //    virtual AsyncCall::Pointer callback() const { return new Call_(call); };