public void Get(VoosAsset asset, ProcessAsset process) { string uri = asset.GetUri(); if (cacheByUri.ContainsKey(uri)) { // We could call process immediately, but that makes this inconsistent. // We should maintain the invariant that process is ALWAYS called asynchronously. StartCoroutine(DeferredProcess(asset, process)); } else { if (activeDownloadWaiters.ContainsKey(uri)) { // Someone else already requested this, so just add ourselves to the wait list. activeDownloadWaiters[uri].Add(process); } else { // Start a new wait list. List <ProcessAsset> waitList = new List <ProcessAsset>(); waitList.Add(process); activeDownloadWaiters[uri] = waitList; // Kick off the download. asset.Accept(new DownloadVisitor(this)); } } }
IEnumerator DeferredProcess(VoosAsset asset, ProcessAsset process) { yield return(null); process(cacheByUri[asset.GetUri()]); }
public void Get(string uri, ProcessAsset process) { Debug.Assert(uri != null); Debug.Assert(uri.Length > 0); Get(VoosAssetUtil.AssetFromUri(uri), process); }