Пример #1
0
        public void ConcurrentHashing()
        {
            var content             = ThreadSafeRandom.GetBytes(1024);
            var hashers             = Enumerable.Range(0, 25).Select(i => _hashInfo.CreateContentHasher()).ToList();
            var expectedContentHash = hashers.First().GetContentHash(content);

            Parallel.ForEach(hashers, hasher =>
            {
                var contentHash = hasher.GetContentHash(content);
                Assert.Equal(expectedContentHash, contentHash);
            });
        }
Пример #2
0
        /// <summary>
        /// Disposes the hasher to save on memory when the server mode process runs
        /// </summary>
        public static void DisposeAndResetHasher()
        {
            s_hasher?.Dispose();
            s_hasher = HashInfo.CreateContentHasher();

            foreach (var hasher in s_contentHasherByHashType.Values)
            {
                hasher.Dispose();
            }
            s_contentHasherByHashType = new ConcurrentDictionary <HashType, IContentHasher>();
        }
Пример #3
0
 /// <summary>
 /// Disposes the hasher to save on memory when the server mode process runs
 /// </summary>
 public static void DisposeAndResetHasher()
 {
     s_hasher?.Dispose();
     s_hasher = HashInfo.CreateContentHasher();
 }