Exemple #1
0
        public Multi(int[] bufferSizes, int[] cacheSizes, bool clear = true, IAllocEvents allocEvents = null, IAllocEvents cacheEvents = null)
        {
            if (bufferSizes == null || bufferSizes.Length <= 0)
            {
                throw new ArgumentException("Buffer sizes array is null or empty", nameof(bufferSizes));
            }

            if (cacheSizes == null || cacheSizes.Length <= 0)
            {
                throw new ArgumentException("Cache sizes array is null or empty", nameof(bufferSizes));
            }

            if (bufferSizes.Length != cacheSizes.Length)
            {
                throw new ArgumentException("Cache sizes array length must match Buffer sizes array length", nameof(cacheSizes));
            }

            if (bufferSizes.Distinct().Count() != bufferSizes.Length)
            {
                throw new ArgumentException("Duplicated Buffer sizes are not allowed", nameof(bufferSizes));
            }

            _managers = Enumerable.Range(0, bufferSizes.Length - 1)
                        .Select(i => new Standard <T>(clear, bufferSizes[i], allocEvents, cacheEvents, cacheSizes[i]))
                        .OrderBy(m => m.BufferSize)
                        .ToArray();

            _bufferSizes = _managers.Select(m => m.BufferSize).ToArray();
        }
Exemple #2
0
        public Standard(bool clear = true, int bufferSize = DefaultBufferSize, IAllocEvents allocEvents = null, IAllocEvents cacheEvents = null, int cacheSize = DefaultCacheSize)
        {
            if (bufferSize <= 0)
            {
                throw new ArgumentException("Buffer size must be bigger than 0", nameof(bufferSize));
            }

            _standard = new StandardInternal <IntPtr>(new UnmanagedAllocator(), clear, bufferSize, cacheSize, allocEvents, cacheEvents);
        }
Exemple #3
0
 public Standard(bool clear = true, IAllocEvents allocEvents = null, IAllocEvents cacheEvents = null, int cacheSize = DefaultCacheSize)
     : this(clear, GetBufferSize(), allocEvents, cacheEvents, cacheSize)
 {
 }
Exemple #4
0
 public Simple(IAllocEvents allocEvents = null)
 {
     _events = allocEvents;
 }
Exemple #5
0
 internal BuffersHashSet(int bufferSize, IAllocEvents events)
 {
     _bufferSize = bufferSize;
     _events     = events;
 }
Exemple #6
0
        public StandardInternal(IAllocator <T> allocator, bool clear, int bufferSize, int cacheSize, IAllocEvents allocEvents, IAllocEvents cacheEvents)
        {
            if (bufferSize <= 0)
            {
                throw new ArgumentException("Buffer size must be bigger than 0", nameof(bufferSize));
            }

            _allocator  = allocator;
            _clear      = clear;
            _bufferSize = bufferSize;
            _buffers    = new BuffersHashSet <T>(bufferSize, allocEvents);
            _cache      = new BuffersStack <T>(bufferSize, cacheEvents, cacheSize);
        }
Exemple #7
0
 internal BuffersStack(int bufferSize, IAllocEvents events, int maxSize)
 {
     _bufferSize = bufferSize;
     _events     = events;
     _maxCount   = maxSize / bufferSize;
 }
Exemple #8
0
 public Simple(bool clear = true, IAllocEvents allocEvents = null)
 {
     _clear  = clear;
     _events = allocEvents;
 }