Exemple #1
0
 private static void NotifyFileLoadedAsync(DataManager me, DataManager.DataManagerLoadRequest request)
 {
     if (request.Prewarm != null)
     {
         if (DebugLog)
         {
             Trace("Notified Prewarm Async: " + GetKey(request));
         }
         List <PrewarmRequest> pre = (List <PrewarmRequest>)prewarmRequests.GetValue(me);
         pre.Remove(request.Prewarm);
     }
     if (DebugLog)
     {
         Trace("Notified Done Async: " + GetKey(request));
     }
     CheckMechDefDependencies(request);
     if (CheckAsyncRequestsComplete())
     {
         if (DebugLog)
         {
             Verbo("Background queue cleared by {0}.", GetKey(request));
         }
         isLoadingAsync.SetValue(me, false);
         SaveCache.Invoke(me, null);
         background.Clear();
         center.PublishMessage(new DataManagerAsyncLoadCompleteMessage());
     }
 }
Exemple #2
0
        private static bool GraduateBackgroundRequest(DataManager me, BattleTechResourceType resourceType, string id)
        {
            string key = GetKey(resourceType, id);

            if (!background.TryGetValue(key, out DataManager.DataManagerLoadRequest dataManagerLoadRequest))
            {
                return(false);
            }
            if (DebugLog)
            {
                Info("Graduating {0} ({1}) from background to foreground.", GetKey(dataManagerLoadRequest), dataManagerLoadRequest.GetType());
            }
            dataManagerLoadRequest.SetAsync(false);
            dataManagerLoadRequest.ResetRequestState();
            background.Remove(key);
            foreground.Add(key, dataManagerLoadRequest);
            if (LoadingQueue && !dataManagerLoadRequest.IsComplete())
            {
                foregroundLoading.Add(dataManagerLoadRequest);
            }
            bool wasLoadingAsync = (bool)isLoadingAsync.GetValue(me);
            bool nowLoadingAsync = !CheckAsyncRequestsComplete();

            if (nowLoadingAsync != wasLoadingAsync)
            {
                isLoadingAsync.SetValue(me, nowLoadingAsync);
                if (wasLoadingAsync)
                {
                    SaveCache.Invoke(me, null);
                    background.Clear();
                    center.PublishMessage(new DataManagerAsyncLoadCompleteMessage());
                }
            }
            return(true);
        }
Exemple #3
0
 private static void NotifyFileLoaded(DataManager me, DataManager.DataManagerLoadRequest request, ref bool isLoading)
 {
     if (request.Prewarm != null)
     {
         if (DebugLog)
         {
             Trace("Notified Prewarm: {0}", GetKey(request));
         }
         List <PrewarmRequest> pre = (List <PrewarmRequest>)prewarmRequests.GetValue(me);
         pre.Remove(request.Prewarm);
     }
     if (DebugLog)
     {
         Trace("Notified Done: {0}", GetKey(request));
     }
     CheckMechDefDependencies(request);
     if (LoadingQueue && request.IsComplete())
     {
         foregroundLoading.Remove(request);
     }
     if (CheckRequestsComplete())
     {
         if (foreground.Count > 0)
         {
             stopwatch.Stop();
             Info("Foreground queue ({0}) cleared. {1:n0}ms this queue, {2:n0}ms total.", foreground.Count, stopwatch.ElapsedMilliseconds, totalLoadTime += stopwatch.ElapsedMilliseconds);
             stopwatch.Reset();
         }
         else if (DebugLog)
         {
             Verbo("Empty foreground queue cleared by {0}.", GetKey(request));
         }
         isLoading = false;
         SaveCache.Invoke(me, null);
         foreground.Clear();
         if (LoadingQueue)
         {
             foregroundLoading.Clear();
         }
         depender.Clear();
         dependee.Clear();
         center.PublishMessage(new DataManagerLoadCompleteMessage());
     }
 }