[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squid-dev
Subject:    Re: weak pointers, cbdata, refcounting
From:       Henrik Nordstrom <hno () squid-cache ! org>
Date:       2005-08-26 20:02:48
Message-ID: Pine.LNX.4.61.0508262141440.22640 () localhost ! localdomain
[Download RAW message or body]

On Mon, 22 Aug 2005, Alex Rousskov wrote:

> 	That's good to know! Apparently, I do not use cbdata correctly 
> because it does not seem to work for me. Could you please point me to the 
> updated (with respect to classes) cbdata docs or notes? Perhaps I just need 
> to add more #define-driven glue to base (or all?) classes...

In each class which needs to support cbdata you need to use the 
CBDATA_CLASS2() macro in the private section. (the brother macro 
CBDATA_CLASS can also be used but you must then manually define new/delete 
methods)

In a suitable .cc file you need to have the CBDATA_CLASS_INIT() macro call 
at global scope.

This works for classes with simple inheritance only, or the leaf classes 
when there is multiple inheritance. It won't work for the inherited 
classes in multiple inheritance.

Classes inheriting a cbdata class must themselves also be defined as an 
cbdata class.

It should perhaps be noted in this discussion that the cbdataReference 
pointer is only meant to be used as an opaqueue pointer. If you need to 
access the members/methods then cbdata is not the proper tool for the job 
(refcounting with invalidation would be).

Regards
Henrik
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic