Пример #1
0
            private void Unload(bool disposing)
            {
                if (_realComposedLut == null)
                {
                    return;
                }

                lock (_syncLock)
                {
                    if (_realComposedLut == null)
                    {
                        return;
                    }

                    Diagnostics.OnLargeObjectReleased(_largeObjectData.BytesHeldCount);
                    //We can't return a buffer to the pool unless we're certain it's not
                    //being used anywhere else, which means this cache item must be
                    //being disposed.
                    if (disposing)
                    {
                        _bufferCache.Return(_realComposedLut.Data);
                    }

                    _realComposedLut = null;
                    _largeObjectData.BytesHeldCount   = 0;
                    _largeObjectData.LargeObjectCount = 0;
                    MemoryManager.Remove(this);
                }
            }
Пример #2
0
            public IComposedLut GetLut(LutCollection sourceLuts)
            {
                IComposedLut lut = _realComposedLut;

                if (lut != null)
                {
                    return(lut);
                }

                lock (_syncLock)
                {
                    if (_realComposedLut != null)
                    {
                        return(_realComposedLut);
                    }

                    //Trace.WriteLine(String.Format("Creating Composed Lut '{0}'", Key), "LUT");

                    _realComposedLut = new ComposedLut(sourceLuts, _bufferCache);
                    //just use the creation time as the "last access time", otherwise it can get expensive when called in a tight loop.
                    _largeObjectData.UpdateLastAccessTime();
                    _largeObjectData.BytesHeldCount   = _realComposedLut.Data.Length * sizeof(int);
                    _largeObjectData.LargeObjectCount = 1;
                    MemoryManager.Add(this);
                    Diagnostics.OnLargeObjectAllocated(_largeObjectData.BytesHeldCount);

                    return(_realComposedLut);
                }
            }