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 pro开发者_C百科vide 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.
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
精彩评论