/// <summary> /// Add Collection to the Collections' Pool /// </summary> /// <param name="collection"></param> public void AddToPool(Algorithm.Collection.ICollectionOnDisk collection) { if (IsClosing) { CollectionsPool.Remove(collection.InMemoryId); } else { //if (!CollectionsPool.Contains(CollName)) CollectionsPool[collection.InMemoryId] = collection; } }
/// <summary> /// Close the file /// </summary> public virtual void Close() { if (IsClosing || _store == null || _store.FileStream == null) { return; } if (IsDirty) { Flush(); } if (_storeAddress == -1) { _storeAddress = _store.DataAddress; } IsClosing = true; try { if (DeletedCollections != null) { DeletedCollections.Close(); if (_deletedCollectionsAddress == -1) { _deletedCollectionsAddress = DeletedCollections.DataAddress; } } if (CollectionsPool != null && CollectionsPool.Count > 0) { var colls = new Algorithm.Collection.ICollectionOnDisk[CollectionsPool.Count]; CollectionsPool.Values.CopyTo(colls, 0); for (int i = 0; i < colls.Length; i++) { colls[i].Close(); } CollectionsPool.Clear(); } if (_store != null) { _store.Close(); } _store = null; if (_diskBuffer != null) { _diskBuffer.ClearData(); } } finally { IsClosing = false; } }
protected internal void RemoveFromPool(Algorithm.Collection.ICollectionOnDisk collection, bool willClose) { if (CollectionsPool != null) { var cod = collection; if (cod != null) { if (willClose) { cod.Close(); } CollectionsPool.Remove(collection.InMemoryId); } } }