Exemplo n.º 1
0
        internal CachedGraphLoader TryLoad(
            LoggingContext loggingContext,
            CancellationToken cancellationToken,
            Guid graphIdOfGraphToReload)
        {
            if (m_graphId != graphIdOfGraphToReload)
            {
                Logger.Log.DisposedEngineStateDueToGraphId(loggingContext);
                Dispose();
                return(null);
            }

            var graphLoader = CachedGraphLoader.CreateFromEngineState(cancellationToken, this);

            Contract.Assert(graphLoader != null);

            // The graph is loaded from the engine state.
            Logger.Log.ReusedEngineState(loggingContext);

            return(graphLoader);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the cache graph store in the given directory
        /// </summary>
        public static async Task <CachedGraph> LoadAsync(string cachedGraphDirectory, LoggingContext loggingContext, bool preferLoadingEngineCacheInMemory, FileSystemStreamProvider readStreamProvider = null)
        {
            // preferLoadingEngineCacheInMemory will be removed after ExecutionLog.cs is updated in OSGTools.
            var unused = preferLoadingEngineCacheInMemory;
            CachedGraphLoader loadingGraph = CachedGraphLoader.CreateFromDisk(CancellationToken.None, cachedGraphDirectory, loggingContext, readStreamProvider);
            var graphId = await loadingGraph.GetOrLoadPipGraphIdAsync();

            // Use a the cached graph based on graph id if already in memory
            if (s_loadedCachedGraphs.TryGetValue(graphId, out var weakCachedGraph) &&
                weakCachedGraph.TryGetTarget(out var cachedGraph))
            {
                return(cachedGraph);
            }

            cachedGraph = await loadingGraph.GetOrLoadCachedGraphAsync();

            if (cachedGraph?.PipGraph != null)
            {
                s_loadedCachedGraphs.AddItem(cachedGraph.PipGraph.GraphId, new WeakReference <CachedGraph>(cachedGraph));
            }

            return(cachedGraph);
        }