public PropertyDatabaseView(PropertyDatabase propertyDatabase, PropertyDatabaseVolatileMemoryStore volatileMemoryStore, PropertyDatabaseMemoryStore memoryStore, PropertyDatabaseFileStore fileStore, PropertyStringTable stringTable, bool delayedSync)
 {
     m_PropertyDatabase        = propertyDatabase;
     m_MemoryStore             = memoryStore;
     m_FileStore               = fileStore;
     m_VolatileMemoryStoreView = (PropertyDatabaseVolatileMemoryStoreView)volatileMemoryStore.GetView();
     m_MemoryStoreView         = (PropertyDatabaseMemoryStoreView)memoryStore.GetView();
     m_FileStoreView           = (PropertyDatabaseFileStoreView)fileStore.GetView();
     m_StringTableView         = stringTable.GetView(delayedSync);
     m_Disposed    = false;
     m_DelayedSync = delayedSync;
 }
Example #2
0
 public PropertyDatabaseFileStoreView(string filePath, PropertyDatabaseFileStore store)
 {
     length     = 0;
     m_Disposed = false;
     m_Fs       = null;
     m_Br       = null;
     m_Bw       = null;
     m_Store    = store;
     // All fields must be assigned before calling any functions.
     store.RegisterFileStoreChangedHandler(HandleFileStoreChanged);
     store.RegisterFileStoreAboutToChangeHandler(HandleFileStoreAboutToChange);
     OpenFileStream(filePath);
 }
Example #3
0
 public void Dispose()
 {
     if (m_Disposed)
     {
         return;
     }
     m_Store.UnregisterFileStoreChangedHandler(HandleFileStoreChanged);
     m_Store.UnregisterFileStoreAboutToChangeHandler(HandleFileStoreAboutToChange);
     m_Br?.Dispose();
     m_Br = null;
     m_Bw?.Dispose();
     m_Bw = null;
     m_Fs?.Dispose();
     m_Fs       = null;
     m_Store    = null;
     m_Disposed = true;
 }
        public PropertyDatabase(string filePath, bool autoBackgroundUpdate, double backgroundUpdateDebounceInSeconds = k_DefaultBackgroundUpdateDebounceInSeconds)
        {
            this.filePath        = filePath;
            stringTableFilePath  = GetStringTablePath(filePath);
            m_LocalVolatileStore = new PropertyDatabaseVolatileMemoryStore();
            m_LocalStore         = new PropertyDatabaseMemoryStore();
            m_FileStore          = new PropertyDatabaseFileStore(filePath);
            m_StringTable        = new PropertyStringTable(stringTableFilePath, 30);

            // Do not allow automatic background updates while running tests. The writing of the file
            // causes an assembly leak during the test Unity.IntegrationTests.Scripting.AssemblyReloadTest.AssemblyReloadDoesntLeakAssemblies
            // on MacOs. I haven't found out why exactly does the writing of a file causes an assembly to be held, so instead I deactivate
            // the automatic update during tests.
            this.autoBackgroundUpdate = autoBackgroundUpdate && !Utils.IsRunningTests();

            m_Debounce = Delayer.Debounce(_ => TriggerPropertyDatabaseBackgroundUpdate(), backgroundUpdateDebounceInSeconds);
        }
        public void Dispose()
        {
            if (m_Disposed)
            {
                return;
            }

            if (m_DelayedSync)
            {
                Sync();
            }

            m_PropertyDatabase = null;
            m_MemoryStore      = null;
            m_FileStore        = null;
            m_VolatileMemoryStoreView.Dispose();
            m_MemoryStoreView.Dispose();
            m_FileStoreView.Dispose();
            m_StringTableView.Dispose();
            m_DelayedSync = false;
            m_Disposed    = true;
        }