コード例 #1
0
        /// <summary>
        /// Serializes and deserializes graph fragments synchronously according to its dependency relation specified by their order in the array.
        /// </summary>
        /// <param name="fragments">Graph fragments with total order on their dependency relation.</param>
        /// <returns>Resulting pip graph.</returns>
        private PipGraph SerializeDeserializeFragmentsSynchronously(params TestPipGraphFragment[] fragments)
        {
            var streams = SerializeFragmentsSynchronously(fragments);

            var fragmentManager = new PipGraphFragmentManager(LoggingContext, Context, PipGraphBuilder);

            for (int i = 0; i < streams.Length; ++i)
            {
                XAssert.IsTrue(fragmentManager.AddFragmentFileToGraph(streams[i], fragments[i].ModuleName));
            }

            DisposeStreams(streams);

            return(PipGraphBuilder.Build());
        }
コード例 #2
0
        /// <summary>
        /// Serializes and deserializes graph fragments in parallel.
        /// </summary>
        /// <param name="fragments">Graph fragments.</param>
        /// <returns>Resulting pip graph.</returns>
        /// <remarks>
        /// The graph fragments, <paramref name="fragments"/>, are serialized synchronously, but are deserialized in parallel.
        /// For correctness, the graph fragments in <paramref name="fragments"/> are assumed to be independent of each other.
        /// </remarks>
        private PipGraph SerializeDeserializeFragmentsInParallel(params TestPipGraphFragment[] fragments)
        {
            var streams = SerializeFragmentsSynchronously(fragments);

            var fragmentManager = new PipGraphFragmentManager(LoggingContext, Context, PipGraphBuilder);

            Parallel.For(
                0,
                fragments.Length,
                i =>
            {
                XAssert.IsTrue(fragmentManager.AddFragmentFileToGraph(streams[i], fragments[i].ModuleName));
            });

            DisposeStreams(streams);

            return(PipGraphBuilder.Build());
        }