Re: Re: Re: Documentation for QBasicAutomic?

Hi Anders,

You’re completely right about QSharedDataPointer! We should use that instead! I didn’t know the class exists. It’s good to read more docs ;-). Thanks for pointing that out! I just read the docs and will use QSharedDataPointer for Packet’s private data.

Many thanks!

Regards,

Peter

Anders wrote:

Hey guys,

The reason you can’t find any documentation on QBasicAtomic is that it is a nitty-gritty Qt internal - not at all part of the public API. Using QBasicAtomic is like playing in heavy traffic - not a recommended activity - and I advice that we stay far away from it (and other Qt internals). The reason is that due to not being part of the public API, Trolltech are free to change it or even completely remove it from Qt, at any time and for any reason they see fit, without even giving anyone a 3 second notice. This of course would break our code.

I might be mentally challenged or simply just a feeble wuss - but why on earth would we want to use the QBasicAtomic anyway? Critical sections of code can be secured with the QMutex or QMutexLocker. Reference counting? No reasons to do this ourself as QSharedData and QSharedDataPointer can handle it for us.

Just my 5 cents.

I could be wrong of course - wouldn’t be the first time ;-)

Cheers,

Anders

Peter Dimov wrote:

Hi Atul,

The only documentation I’m aware of and which I used myself is the source code of Qt :-P. Just search for QBasicAtomic in $QTDIR/src and you’ll find its implementation and some real-life examples how to use it.

In a nutshell, it provides you atomic operations, which you’ll need to make sure that reference counters don’t get corrupted in a multithreaded environment. I think I learned a lot when as I was implementing reference counting in Packet. It’s really tricky to do right, but once you have a working example it’s much easier.

That’s another aspect that needs to be tested! Does reference counting on Packet’s private data (and in general for other classes) work right? Maybe some stress test involving multiple threads is required. Any ideas?

Regards,

Peter

atul wrote:Any idea …. I am not able to find it anywhere in Qt docs…

– cheers atul

Would you like to post a relpy?


This post is a reply to:
Re: Re: Documentation for QBasicAutomic?
Hey guys, The reason you can't find any documentation on QBasicAtomic is that it is a nitty-gritty Qt internal - not at all part of the public API. Using QBasicAtomic is (more...)

No follow-ups yet.