[Qt-interest] Safety of Passing by Reference with Signals and Slots
Will Rutherdale (rutherw)
rutherw at cisco.com
Fri May 1 18:18:08 CEST 2009
Hi.
I just joined this list. I am investigating Qt for a project that will
use only console applications (QCoreApplication), in an embedded
environment.
I was experimenting with running background computations (which take
time to execute) on threads. At the end of the computation, the results
have to be reported in a data structure, back to a controlling object.
For this purpose I use connect() with Qt::QueuedConnection and emit.
Right now the signal and slot prototypes look something like this:
signals: // in computation class
void sigSendResult( ResultStruct const &ppr );
private slots: // in control class
void reportResult( ResultStruct const &ppr );
My question is this: how safe is it to pass by reference in this
situation?
Is there any danger of a race condition? For instance, if the method
doing the 'emit' terminates before the request is queued, could there be
data corruption? Are there ways to control this and make it reliable?
So far I haven't seen any failures in my test code, but I couldn't find
any documentation so far indicating when pass-by-reference is safe.
I would appreciate any help on this question.
-Will
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090501/e81ba57e/attachment.html
More information about the Qt-interest-old
mailing list