resourcesuser.cpp
27 // This class is needed so that the status of m_beingNotified is exception safe (i.e. it is reset
28 // to false if an exception gets thrown inside the handler for resource change). This is used both
100 // This is not exception safe. It is difficult to make this exception safe because QT aren't (and here we
109 // This is not exception safe. It is difficult to make this exception safe because QT aren't (and here we
165 void SimpleResourcesUser::notifyResourceChange(ResourceHandler* resource, ResourceChangeType changeType)
219 // parts of the if are similar but trying to merge them creates quite some problems (with locks and
222 // Acquiring the lock on old resources to remove notifications, then we can release it. I'm doing
224 // ok (even if the mutex is unlocked). The mutex could be destroyed together with the corresponding
225 // ResourceCollection in ResourcesUser::shareResourcesWith(). Here we also get the list of name of
234 for (QMap<QString, ResourceHandler*>::const_iterator it = m_usableResources.constBegin(); it != m_usableResources.constEnd(); ++it) {
247 // Now we have to update the m_usableResources map to point the the new resource handlers. No resource
249 for (QMap<QString, ResourceHandler*>::iterator it = m_usableResources.begin(); it != m_usableResources.end(); ++it) {
254 // Before sending notifications, we have to get the lock on all resources and to release the lock on the
269 // Acquiring the lock on old resources to remove notifications, then we can release it. I'm doing
271 // ok (even if the mutex is unlocked). The mutex could be destroyed together with the corresponding
272 // ResourceCollection in ResourcesUser::shareResourcesWith(). Here we also get the list of name of
281 for (QMap<QString, ResourceHandler*>::const_iterator it = m_usableResources.constBegin(); it != m_usableResources.constEnd(); ++it) {
288 // Calling parent function to actually share resources. Here the lock on new resources would be taken
289 // again (but the mutex is not recursive), so we have to temporarly prevent m_resources from locking
294 // Now we have to update the m_usableResources map to point the the new resource handlers. We also create
297 for (QMap<QString, ResourceHandler*>::iterator it = m_usableResources.begin(); it != m_usableResources.end(); ++it) {
306 // Before sending notifications, we have to get the lock on all resources and to release the lock on the
313 // Now we can send all notifications. The changeType to use depends on the status of the resource with a given
314 // name in the new and old set: if a resource existed in the old set and not in the new one, changeType will be
315 // Deleted, if it existed in the old set and is also present in the new one, changeType will be Modified, if it
317 const QSet<QString> deletedResources = m_existingResourcesInOldCollection - m_existingResourcesInNewCollection;
318 const QSet<QString> modifiedResources = m_existingResourcesInOldCollection & m_existingResourcesInNewCollection;
319 const QSet<QString> createdResources = m_existingResourcesInNewCollection - m_existingResourcesInOldCollection;
340 // First of all we have to acquire the lock on the Resource Manager (because we need to call getResource)
354 // Getting the lock on all new resources to send notifications. There is a little overhead, here,
375 // First of all we have to acquire the lock on the Resource Manager (because we need to call getResource)
403 // First of all we have to acquire the lock on the Resource Manager (because we need to call getResource)
419 // Getting the lock on all new resources to send notifications. There is a little overhead, here,
441 // First of all we have to acquire the lock on the Resource Manager (because we need to call getResource)
467 // First of all we have to acquire the lock on the Resource Manager (because we need to call getResource)
477 // Taking the resource handler and then removing the resource (the resource must exist, otherwise there is a
488 // Getting the lock on all deleted resources to send notifications. There is a little overhead, here,
509 // First of all we have to acquire the lock on the Resource Manager (because we need to call getResource)
521 // Getting the lock on all deleted resources to send notifications. There is a little overhead, here,
603 // Locking all resources. To avoid deadlocks here we first acquire the lock on the Resource Manager
614 // Unlocking all resources. Here we have to take the mutex because the unlock of resources must be
615 // atomic (otherwise a lockAll() call can find a resource locked even if we are here because we haven't
627 void ConcurrentResourcesUser::notifyResourceChange(ResourceHandler* resource, ResourceChangeType changeType)
661 // Now locking all our resources. The mutexes for resources are recursive, so they will not fail