<commit_before>﻿using System;

namespace WeihanLi.Common
{
    /// <summary>
    /// A singleton disposable that does nothing when disposed.
    /// </summary>
    public sealed class NullDisposable : IDisposable
    {
        private NullDisposable()
        {
        }

        public void Dispose()
        {
        }

        /// <summary>
        /// Gets the instance of <see cref="NullDisposable"/>.
        /// </summary>
        public static NullDisposable Instance { get; } = new NullDisposable();
    }<commit_msg>add DisposableAction<commit_after>﻿using System;
using System.Threading;

namespace WeihanLi.Common
{
    /// <summary>
    /// A singleton disposable that does nothing when disposed.
    /// </summary>
    public sealed class NullDisposable : IDisposable
    {
        private NullDisposable()
        {
        }

        public void Dispose()
        {
        }

        /// <summary>
        /// Gets the instance of <see cref="NullDisposable"/>.
        /// </summary>
        public static NullDisposable Instance { get; } = new NullDisposable();
    }

    public sealed class DisposableAction : IDisposable
    {
        public static readonly DisposableAction Empty = new DisposableAction(null);

        private Action _disposeAction;

        public DisposableAction(Action disposeAction)
        {
            _disposeAction = disposeAction;
        }

        public void Dispose()
        {
            Interlocked.Exchange(ref _disposeAction, null)?.Invoke();
        }
    }
{'fraction_non_alphanumeric': 0.09940750493745885, 'fraction_numerical': 0.0, 'mean_word_length': 1.9343629343629343, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '1771259', 'n_tokens_mistral': 422, 'n_tokens_neox': 385, 'n_words': 107}