|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
That way we prevent the current possible race condition that may appears
while touching signals slot while object are moved to different threads.
For exemple, when we do sender->threadData->mutex->lock(); the sender
can possibly be moved to another thread between the moment we get the
pointer to the threadData and the moment we aquire the lock. We could
check if we locked the right mutex and retry otherwise, but that would
break if the threadData (and hence the mutex) get destroyed in between.
The per object mutex is implemented with a thread pool.
I'm not using the global QThreadPool because we might ends up locking
two of their mutex, and that would be dangerous if something else holds
a lock on the same mutex (possible deadlock)
Putting the mutex pool in a Q_GLOBAL_STATIC doesn't work as it might
result of the ppol being deleted before some other object in others
Q_GLOBAL_STATIC structures
There is no need to lock this mutex in moveToThread as this is safe.
When emiting a signal, we do not need to lock the thread data, as the
user must ensure that the object is not moved to a thread while emiting
a AutoConnection signal.
Reviewed-by: Brad
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
while using QOrderedMutexLocker::relock we might unlock our mutex
protecting the 'senders' list for a short moment. Another thread may then
modify or remove element on the list.
Therefore, we need to recheck the consistency of the list once we did
that.
Also, we cannot call removeSender because that will remove every
connections, making impossible for another object destroyed in the same
time to clean up the senders list, so call derefSender instead.
Reviewed-by: Brad
|