[Telepathy] tq-qt4 refcount proposal

Kenneth Rohde Christiansen kenneth.christiansen at gmail.com
Thu Mar 26 06:47:16 PDT 2009


When working with templates you should be aware of library size
growth, so if you don't need these functions it might make sense
copying the code and removing want you dont need, and look at using
template hoisting like webkit does for its RefCounted class, which
basically boils down to:

 89 template<class T> class RefCounted : public RefCountedBase {
 90 public:
 91     void deref()
 92     {
 93         if (derefBase())
 94             delete static_cast<T*>(this);
 95     }
 96
 97 protected:
 98     ~RefCounted() {}
 99 };

The idea is that everything in RefCounted that doesn't require T is
put in RefCountedBase, thus minimizing size growth. You can also use
the WebKit classes they are LGPL.

Cheers,
Kenneth



> Having a class that inherits QExplicitlySharedDataPointer doesn't really
> future proof you, since any replacement must implement the exact same api. I
> suppose if you privately inherit you could maybe get away with it, might be a
> good idea to get rid of detach() anyways.
>
>> So the usage would be:
>>
>> public Account : SharedData
>> {
>> public:
>> ...
>> static SharedPtr<Account> create();
>> ...
>> };
>
> Regardless I think even if you have a SharedPtr, you should typedef
> SharedPtr<Account> into AccountPtr because its annoying to use templates in
> the code all the time. :)
>
>> I wrote a experimental branch to ilustrate what it's explained above
>> http://git.collabora.co.uk/?p=user/andrunko/telepathy-qt4.git;a=shortlog;h=
>>refs/heads/shared
>>
>> Opinions, suggestions?
>
> Well you know I think its a good idea. :)
>
> Ian
>
> _______________________________________________
> telepathy mailing list
> telepathy at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/telepathy
>
>



-- 
Kenneth Rohde Christiansen
http://kenneth.christiansen.googlepages.com


More information about the telepathy mailing list