<commit_before>﻿using System;
using System.Collections.Concurrent;
using System.Threading;

namespace Examples
{
    public class SynchronizedConcurrentDictionary<TKey, TValue> : ConcurrentDictionary<TKey, TValue>
    {
        private readonly ReaderWriterLockSlim _cacheLock = new ReaderWriterLockSlim();

        public new TValue AddOrUpdate(TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)
        {
            _cacheLock.EnterWriteLock();
            try
            {
                return base.AddOrUpdate(key, addValue, updateValueFactory);
            }
            finally
            {
                _cacheLock.ExitWriteLock();
            }
        }

        public new TValue AddOrUpdate(TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)
        {
            _cacheLock.EnterWriteLock();
            try
            {
                return base.AddOrUpdate(key, addValueFactory, updateValueFactory);
            }
            finally
            {
                _cacheLock.ExitWriteLock();
            }
        }

        public new TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)
        {
            TValue result;

            _cacheLock.EnterWriteLock();
            try
            {
                result = base.GetOrAdd(key, valueFactory);
            }
            finally
            {
                _cacheLock.ExitWriteLock();
            }

            return result;
        }
    }
}<commit_msg>Removed SynchronizedConcurrentDictionary methods unneccesary for presentation.<commit_after>﻿using System;
using System.Collections.Concurrent;
using System.Threading;

namespace Examples
{
    public class SynchronizedConcurrentDictionary<TKey, TValue> : ConcurrentDictionary<TKey, TValue>
    {
        private readonly ReaderWriterLockSlim _cacheLock = new ReaderWriterLockSlim();

        public new TValue AddOrUpdate(TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)
        {
            _cacheLock.EnterWriteLock();
            try
            {
                return base.AddOrUpdate(key, addValue, updateValueFactory);
            }
            finally
            {
                _cacheLock.ExitWriteLock();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07242582897033159, 'fraction_numerical': 0.0, 'mean_word_length': 1.834363411619283, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '931790', 'n_tokens_mistral': 608, 'n_tokens_neox': 594, 'n_words': 122}