public static void InitialiseRAMDatabase() { lock (databaseRAMLocker) { if (nonRAMDatabaseStarted) { throw new Exception("Cannot initialise the RAM database if main database connections have been established."); } else { databaseRAM = new RAMDatabase(true); } } }
public static void ResetRAMDatabase() { lock (databaseRAMLocker) { if (nonRAMDatabaseStarted || databaseRAM == null) { throw new Exception("RAM database cannot be reset if it has not yet been initialised or being used in nonRAM mode."); } else { databaseRAM = new RAMDatabase(true); } } }
/// <summary> /// Create a database snapshot /// </summary> /// <param name="currentRAMDatabase"></param> public DatabaseSnapshot(RAMDatabase currentRAMDatabase) { //If we set the bool to false here and the database changes //while we are copying the lists we happy for the value to go back to true //For now anyway - Thread Safety sucks balls for speed! currentRAMDatabase.databaseChangesSinceLastSnapshot = false; this.snapshotCreationTime = DateTime.Now; dataLists.pokerTablesSnapshot = currentRAMDatabase.ShallowCloneTables(); dataLists.pokerPlayersSnapshot = currentRAMDatabase.ShallowClonePlayers(); dataLists.pokerHandsSnapshot = currentRAMDatabase.ShallowCloneHands(); dataLists.holeCardsSnapshot = currentRAMDatabase.ShallowCloneHoleCads(); dataLists.handActionsSnapshot = currentRAMDatabase.ShallowCloneActions(); }
/// <summary> /// Initialise a new empty cache. This takes an unused int parameter so that the private paramaterless consutrctor can be used for serialisation. /// </summary> protected void baseConstructor(Random randomGen) { tablePlayers = new List <tablePlayer>(); pokerPlayers = new List <pokerPlayer>(); pokerHands = new List <pokerHand>(); holeCards = new List <holeCard>(); handActions = new List <handAction>(); databaseCache.randGen = randomGen; lock (databaseRAMLocker) { if (databaseRAM == null) { nonRAMDatabaseStarted = true; databaseRAM = new RAMDatabase(false); } } }