| 38 | } |
| 39 | |
| 40 | UrlParseLock::UrlParseLock(const IndexedString& url) |
| 41 | : m_url(url) |
| 42 | { |
| 43 | QMutexLocker lock(&parsingUrlsMutex); |
| 44 | |
| 45 | // NOTE: operator[] default-initializes the ptr to zero for us when not available |
| 46 | auto& perUrlData = parsingUrls()[url]; |
| 47 | if (!perUrlData) { |
| 48 | // if that was the case, we are the first to parse this url, create an entry |
| 49 | perUrlData = new PerUrlData; |
| 50 | } |
| 51 | |
| 52 | // always increment the refcount |
| 53 | ++perUrlData->ref; |
| 54 | |
| 55 | // now lock the url, but don't do so while blocking the global mutex |
| 56 | auto& mutex = perUrlData->mutex; |
| 57 | lock.unlock(); |
| 58 | |
| 59 | mutex.lock(); |
| 60 | } |
| 61 | |
| 62 | UrlParseLock::~UrlParseLock() |
| 63 | { |