void WebResourceLoadStatisticsStore::applicationWillTerminate() { BinarySemaphore semaphore; m_statisticsQueue->dispatch([this, &semaphore] { // Make sure any ongoing work in our queue is finished before we terminate. semaphore.signal(); }); semaphore.wait(std::numeric_limits<double>::max()); }
unsigned long long ThreadableBlobRegistry::blobSize(const URL& url) { unsigned long long resultSize; if (isMainThread()) resultSize = blobRegistry().blobSize(url); else { BinarySemaphore semaphore; callOnMainThread([url = url.isolatedCopy(), &semaphore, &resultSize] { resultSize = blobRegistry().blobSize(url); semaphore.signal(); }); semaphore.wait(std::numeric_limits<double>::max()); } return resultSize; }
unsigned long long ThreadableBlobRegistry::blobSize(const URL& url) { unsigned long long resultSize; if (isMainThread()) resultSize = blobRegistry().blobSize(url); else { // BlobRegistryContext performs an isolated copy of data. BlobRegistryContext* context = new BlobRegistryContext(url); BinarySemaphore semaphore; callOnMainThread([context, &semaphore, &resultSize] { std::unique_ptr<BlobRegistryContext> blobRegistryContext(context); resultSize = blobRegistry().blobSize(blobRegistryContext->url); semaphore.signal(); }); semaphore.wait(std::numeric_limits<double>::max()); } return resultSize; }