Ejemplo n.º 1
0
        /// <summary>
        /// Compute the intersection of the pip's dependencies and the affected contents of the build
        /// </summary>
        public IReadOnlyList <AbsolutePath> GetChangeAffectedInputs(Process process)
        {
            var changeAffectedInputs = new HashSet <AbsolutePath>(process.Dependencies.Select(f => f.Path).Where(p => m_sourceChangeAffectedFiles.Contains(p)));

            foreach (var directory in process.DirectoryDependencies)
            {
                foreach (var file in m_fileContentManager.ListSealedDirectoryContents(directory))
                {
                    if (m_sourceChangeAffectedFiles.Contains(file))
                    {
                        changeAffectedInputs.Add(file.Path);
                    }
                }

                if (m_fileContentManager.Host.TryGetSourceSealDirectory(directory, out var sourceSealWithPatterns))
                {
                    var affectedMembers = m_sourceSealDirectoryAffectedMembers.GetOrAdd(
                        directory,
                        d => new List <AbsolutePath>(m_initialSourceChanges.Where(p => sourceSealWithPatterns.Contains(PathTable, p))));
                    changeAffectedInputs.AddRange(affectedMembers);
                }
            }

            return(ReadOnlyArray <AbsolutePath> .FromWithoutCopy(changeAffectedInputs.ToArray()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Whether the mount was defined by a module (as opposed to by the main configuration file, or a static implicit
        /// system mount)
        /// </summary>
        public bool IsModuleDefinedMount(IMount mount)
        {
            Contract.RequiresNotNull(mount);
            Contract.Assert(m_finalized);

            return(m_moduleDefinedMounts.Contains(mount));
        }
        /// <summary>
        /// Compute the intersection of the pip's dependencies and the affected contents of the build
        /// </summary>
        public IReadOnlyCollection <AbsolutePath> GetChangeAffectedInputs(Process process)
        {
            var changeAffectedInputs = new HashSet <AbsolutePath>();

            changeAffectedInputs.AddRange(process.Dependencies.Select(f => f.Path).Where(f => m_sourceChangeAffectedFiles.Contains(f)));

            foreach (var directory in process.DirectoryDependencies)
            {
                foreach (var file in m_fileContentManager.ListSealedDirectoryContents(directory))
                {
                    if (m_sourceChangeAffectedFiles.Contains(file))
                    {
                        changeAffectedInputs.Add(file.Path);
                    }
                }
            }

            return(ReadOnlyArray <AbsolutePath> .FromWithoutCopy(changeAffectedInputs.ToArray()));
        }
Ejemplo n.º 4
0
        private static void TestOperationsHelper(bool parallel)
        {
            var set                = new ConcurrentBigSet <int>();
            int length             = 100000;
            int expectedAddedCount = length;

            var indexedItems = new int[length];

            // Verify that all bits start off with the default value (false in this case)
            For(length, i =>
            {
                XAssert.IsFalse(set.Contains(i));
            }, parallel);

            XAssert.AreEqual(0, set.Count);

            int addedCount = 0;

            // Verify setting bits
            For(length, i =>
            {
                if ((i % 4) == 3)
                {
                    // Introduce some contention for setting the same key.
                    i = i - 1;
                    Interlocked.Decrement(ref expectedAddedCount);
                }

                if ((i % 7) == 3)
                {
                    // Introduce some concurrent read-only operations
                    // in the parallel case
                    set.Contains(i - 2);
                }

                ConcurrentBigSet <int> .GetAddOrUpdateResult result =
                    ((i % 5) != 3) ?
                    set.GetOrAdd(i) :

                    // Test heterogeneous add in set
                    set.GetOrAddItem(new StringIntItem(i.ToString()));

                if (!result.IsFound)
                {
                    Interlocked.Increment(ref addedCount);
                }

                XAssert.AreEqual(i, set[result.Index]);

                // Save where the result claims the index of the item
                // to verify it later.
                indexedItems[result.Index] = i;
            }, parallel);

            XAssert.AreEqual(expectedAddedCount, addedCount);
            XAssert.AreEqual(expectedAddedCount, set.Count);

            For(length, i =>
            {
                XAssert.AreEqual((i % 4) != 3, set.Contains(i));

                // Test heterogeneous search in set
                XAssert.AreEqual((i % 4) != 3, set.ContainsItem(new StringIntItem(i.ToString())));

                if (i < expectedAddedCount)
                {
                    // Verify the order of items doesn't change.
                    XAssert.AreEqual(indexedItems[i], set[i]);
                }
            }, parallel);
        }