From: Amos Jeffries Date: Sat, 11 Sep 2010 15:26:55 +0000 (+1200) Subject: Implement subscription for AsyncCallT / JobCallback X-Git-Tag: take08~55^2~124^2~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4226e15d1acfc0f9b210307faece79f07ea0ed42;p=thirdparty%2Fsquid.git Implement subscription for AsyncCallT / JobCallback --- diff --git a/src/base/AsyncCall.h b/src/base/AsyncCall.h index a1bdaef0c2..0576b33c4e 100644 --- a/src/base/AsyncCall.h +++ b/src/base/AsyncCall.h @@ -121,6 +121,10 @@ public: const Dialer &aDialer): AsyncCall(aDebugSection, aDebugLevel, aName), dialer(aDialer) {} + AsyncCallT(const RefCount > &o): + AsyncCall(o->debugSection, o->debugLevel, o->name), + dialer(o->dialer) {} + CallDialer *getDialer() { return &dialer; } protected: diff --git a/src/base/Subscription.h b/src/base/Subscription.h index 4840260b0a..d1d559595e 100644 --- a/src/base/Subscription.h +++ b/src/base/Subscription.h @@ -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 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 CallSubscription: public Subscription { public: - // cant be const because CommCbFunPtrCallT cant provide a const overload. + CallSubscription(const RefCount &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 &aCall) : call(aCall) {}; virtual AsyncCall::Pointer callback() { return new Call_(call); }; // virtual AsyncCall::Pointer callback() const { return new Call_(call); };