public LatchKey IssueKey(Transaction transaction, LatchMode mode) { var key = new LatchKey(this, transaction, mode); Keys.Add(key); return(key); }
public FarmingHysteresisData(System.WeakReference <Zone_Growing> weakReference) { zoneWeakReference = weakReference; enabled = false; lowerBound = Constants.DefaultHysteresisLowerBound; upperBound = Constants.DefaultHysteresisUpperBound; latchMode = LatchMode.Unknown; }
/// <summary> /// Places a latch (or lock) on an object with the specified mode (shared or exclusive). /// If you plan on initially using a shared lock then potentiall converting to an exclusive, it is generally safer to acquire the exclusive up front. /// Latches are released then the transaction is terminated by commit or rollback. /// </summary> /// <param name="session"></param> /// <param name="logicalSchemaPath"></param> /// <param name="latchMode"></param> public void AcquireSchemaLatch(Session session, string logicalSchemaPath, LatchMode latchMode) { lock (CriticalSections.AcquireLock) { AcquireSingleSchemaLatch(session, logicalSchemaPath, latchMode); var schemaInfo = _core.Schema.Parse(session, logicalSchemaPath); //Place shared locks on all parents of the schema, schemaInfo = _core.Schema.Parse(session, schemaInfo.LogicalParent); while (string.IsNullOrEmpty(schemaInfo.Name) == false) { AcquireSingleSchemaLatch(session, schemaInfo.FullLogicalPath, LatchMode.Shared); schemaInfo = _core.Schema.Parse(session, schemaInfo.LogicalParent); } } }
internal void ExposeData() { Scribe_Values.Look(ref enabled, "farmingHysteresisEnabled", false); Scribe_Values.Look(ref lowerBound, "farmingHysteresisLowerBound", Constants.DefaultHysteresisLowerBound); Scribe_Values.Look(ref upperBound, "farmingHysteresisUpperBound", Constants.DefaultHysteresisUpperBound); Scribe_Values.Look(ref latchMode, "farmingHysteresisLatchMode", LatchMode.Unknown); if (Scribe.mode == LoadSaveMode.LoadingVars) { switch (latchMode) { case LatchMode.AboveLowerBoundDisabled: latchMode = LatchMode.BetweenBoundsDisabled; break; case LatchMode.AboveLowerBoundEnabled: latchMode = LatchMode.BetweenBoundsEnabled; break; } } Scribe_Values.Look(ref useGlobalValues, "farmingHysteresisUseGlobalValues", false); }
/// <summary> /// Places a latch (or lock) on an object with the specified mode (shared or exclusive). /// If you plan on initially using a shared lock then potentiall converting to an exclusive, it is generally safer to acquire the exclusive up front. /// Latches are released then the transaction is terminated by commit or rollback. /// </summary> /// <param name="session"></param> /// <param name="logicalDocumentPath"></param> /// <param name="latchMode"></param> public void AcquireDocumentLatch(Session session, string logicalDocumentPath, LatchMode latchMode) { lock (CriticalSections.AcquireLock) { var schemaInfo = _core.Schema.Parse(session, logicalDocumentPath); //Place shared locks on all parents of the document. schemaInfo = _core.Schema.Parse(session, schemaInfo.LogicalParent); while (string.IsNullOrEmpty(schemaInfo.Name) == false) { AcquireSingleSchemaLatch(session, schemaInfo.FullLogicalPath, LatchMode.Shared); schemaInfo = _core.Schema.Parse(session, schemaInfo.LogicalParent); } //Get or add a new latch on the object. var latch = _latches.AddOrGet(Constants.ObjectType.Document, logicalDocumentPath); //Get a new key to the object. var latchKey = latch.IssueKey(session.CurrentTransaction, latchMode); //Give the latch key to the current transaction. session.CurrentTransaction.AddLatchKey(latchKey); } }
private void AcquireSingleSchemaLatch(Session session, string logicalSchemaPath, LatchMode latchMode) { lock (CriticalSections.AcquireLock) { //TODO: Lookup existing latches to see if there are any that are incompatible with this one. //... //... //... //Get or add a new latch on the object. var latch = _latches.AddOrGet(Constants.ObjectType.Schema, logicalSchemaPath); //Get a new key to the object. var latchKey = latch.IssueKey(session.CurrentTransaction, latchMode); //Give the latch key to the current transaction. session.CurrentTransaction.AddLatchKey(latchKey); } }
public LatchKey(Latch latch, Transaction transaction, LatchMode mode) { Latch = latch; Transaction = transaction; Mode = mode; }
/// <summary> /// Pass-through to the latch engine to AcquireDocumentLatch. /// </summary> /// <param name="session"></param> /// <param name="logicalDocumentPath"></param> /// <param name="latchMode"></param> public void AcquireDocumentLatch(Session session, string logicalDocumentPath, LatchMode latchMode) { _core.Latch.AcquireDocumentLatch(_session, logicalDocumentPath, latchMode); }
/// <summary> /// Pass-through to the latch engine to AcquireSchemaLatch. /// </summary> /// <param name="logicalSchemaPath"></param> /// <param name="latchMode"></param> public void AcquireSchemaLatch(string logicalSchemaPath, LatchMode latchMode) { _core.Latch.AcquireSchemaLatch(_session, logicalSchemaPath, latchMode); }