<commit_before>﻿namespace Foat.Collections.Generic.MMF
{
    using System;
    using System.IO.MemoryMappedFiles;

    /// <summary>
    /// This is a memory mapped file based queue that can store huge numbers of items since its cached on disk.
    /// This version cannot be persisted (yet).
    /// </summary>
    public class ConcurrentMMFQueue : IDisposable
    {
        
        private object Locker = new object();
        private MemoryMappedFile MemoryMappedFile;

        private MMFCache HeadCache;
        private MMFCache TailCache;
        
        private readonly int BytesPerItem;

        private readonly int ItemCapacity;
        private readonly long TotalBytes;
        private readonly int ItemCacheCapacity;

        private int HeadItemIndex;
        private int TailItemIndex;

        public long Count { get; private set; }

        /// <summary>
        /// Creates a new instance of the ConcurrentMMFQueue class.
        /// </summary>
        /// <param name="name">The name of the queue to be used. Two processes using ConcurrentMMFQueues
        /// with the same name will share the same queue.</param>
        /// <param name="bytesPerItem">The queue can deal with bytes in chucks you can read the bytes for
        /// one item all at the same time.</param>
        /// <param name="itemCapacity">The number of items that the queue will store.</param>
        /// <param name="itemCacheCapacity">The number of items that the memory mapped view stream cach will contain.</param>
        public ConcurrentMMFQueue(string name, int bytesPerItem, int itemCapacity, int itemCacheCapacity)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            if (bytesPerItem <= 0)
                throw new ArgumentException("Must be positive.", "bytesPerItem");

            if (itemCapacity <= 0)
                throw new ArgumentException("Must be positive.", "itemCapacity");

            if (itemCacheCapacity <= 0)
                throw new ArgumentException("Must be positive.", "itemCacheCapacity");

            this.BytesPerItem = bytesPerItem;
            this.ItemCapacity = itemCapacity;
            this.TotalBytes = itemCapacity * bytesPerItem;

            this.ItemCacheCapacity = itemCacheCapacity;

            this.HeadItemIndex = 0;
            this.TailItemIndex = 0;
<commit_msg>Fixed the calculation of the total bytes that a ConcurrentMMFQueue will occupy<commit_after>﻿namespace Foat.Collections.Generic.MMF
{
    using System;
    using System.IO.MemoryMappedFiles;

    /// <summary>
    /// This is a memory mapped file based queue that can store huge numbers of items since its cached on disk.
    /// This version cannot be persisted (yet).
    /// </summary>
    public class ConcurrentMMFQueue : IDisposable
    {
        
        private object Locker = new object();
        private MemoryMappedFile MemoryMappedFile;

        private MMFCache HeadCache;
        private MMFCache TailCache;
        
        private readonly int BytesPerItem;

        private readonly int ItemCapacity;
        private readonly long TotalBytes;
        private readonly int ItemCacheCapacity;

        private int HeadItemIndex;
        private int TailItemIndex;

        public long Count { get; private set; }

        /// <summary>
        /// Creates a new instance of the ConcurrentMMFQueue class.
        /// </summary>
        /// <param name="name">The name of the queue to be used. Two processes using ConcurrentMMFQueues
        /// with the same name will share the same queue.</param>
        /// <param name="bytesPerItem">The queue can deal with bytes in chucks you can read the bytes for
        /// one item all at the same time.</param>
        /// <param name="itemCapacity">The number of items that the queue will store.</param>
        /// <param name="itemCacheCapacity">The number of items that the memory mapped view stream cach will contain.</param>
        public ConcurrentMMFQueue(string name, int bytesPerItem, int itemCapacity, int itemCacheCapacity)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            if (bytesPerItem <= 0)
                throw new ArgumentException("Must be positive.", "bytesPerItem");

            if (itemCapacity <= 0)
                throw new ArgumentException("Must be positive.", "itemCapacity");

            if (itemCacheCapacity <= 0)
                throw new ArgumentException("Must be positive.", "itemCacheCapacity");

            this.BytesPerItem = bytesPerItem;
            this.ItemCapacity = itemCapacity;
            this.TotalBytes = (long)itemCapacity * (long)bytesPerItem;

            this.ItemCacheCapacity = itemCacheCapacity;

            this.HeadItemIndex = 0;
            this.TailItemIndex = 0;

{'fraction_non_alphanumeric': 0.08159039138537999, 'fraction_numerical': 0.0020708221163802027, 'mean_word_length': 2.2679296346414075, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 27, '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': '13116', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1145, 'n_words': 439}