Пример #1
0
        private static void GenerateBlobList(int ThreadCount, string Root, ISet <string> Files, ConcurrentDictionary <string, DependencyFile> DepFiles, ConcurrentDictionary <string, DependencyBlob> DepBlobs)
        {
            // Initialize StatFileHelper in main thread for workaroung mono non-theadsafe assembly loading.
            StatFileHelper.IsExecutalbe(".");

            ConcurrentQueue <string> FilesQueue = new ConcurrentQueue <string>(Files);

            Thread[] Threads = new Thread[ThreadCount];
            for (int i = 0; i < Threads.Length; ++i)
            {
                Threads[i] = new Thread(x => GenerateBlobListThread(Root, FilesQueue, DepFiles, DepBlobs));
                Threads[i].Start();
            }
            foreach (Thread T in Threads)
            {
                T.Join();
            }
        }
Пример #2
0
        private static void GenerateBlobListThread(string Root, ConcurrentQueue <string> FilesQueue, ConcurrentDictionary <string, DependencyFile> DepFiles, ConcurrentDictionary <string, DependencyBlob> DepBlobs)
        {
            string PackFile;

            while (FilesQueue.TryDequeue(out PackFile))
            {
                string FullPath = Path.Combine(Root, PackFile);
                long   FileSize;
                // Add File info.
                DependencyFile DepFile = new DependencyFile();
                DepFile.IsExecutable = StatFileHelper.IsExecutalbe(FullPath);
                DepFile.Name         = PackFile;
                DepFile.Hash         = ComputeHashForFile(FullPath, out FileSize);
                if (DepFiles.TryAdd(PackFile, DepFile))
                {
                    // Add Blob info.
                    DependencyBlob DepBlob = new DependencyBlob();
                    DepBlob.Hash = DepFile.Hash;
                    DepBlob.Size = FileSize;
                    DepBlobs.TryAdd(DepBlob.Hash, DepBlob);
                }
            }
        }