Question

i've been trying to find where and how the reference counting for Qt is implemented. The QBasicAtomicInt and QAtomicInt use the ref() and deref() functions which provide an efficient reference counting API. These functions atomically increment and decrement the value but where are these functions implemented in the library? I am trying to understand how exactly Qt implements atomic reference counting. Thank you.

Was it helpful?

Solution

Atomic operations cannot be achieved in plain C++ so they are implemented directly in assembly for each specific processor architecture.

Here is the source for Qt's atomic operations for x86 processors: http://qt.gitorious.org/qt/qt/blobs/4.7/src/corelib/arch/i386/qatomic_i386.s

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top