Class ConcurrencyConflictSolver
Provides conflict resolution context when a write-write conflict is detected during Commit(ConcurrencyConflictHandler).
public class ConcurrencyConflictSolver
- Inheritance
-
ConcurrencyConflictSolver
- Inherited Members
Remarks
During commit, each entity is checked for conflicts (another transaction committed new data since our read). When a conflict is detected and a Typhon.Engine.Internals.ConcurrencyConflictHandler was provided, the solver is populated with the conflicting entity's data, then the handler is invoked once per conflicting entity.
The four data views are:
- ReadData<T>(): the component state our transaction read (its snapshot baseline).
- CommittedData<T>(): the latest committed state by another transaction (the value that caused the conflict).
- CommittingData<T>(): the dirty-write state our transaction staged (what we intended to commit).
- ToCommitData<T>(): the output buffer — initialized with
CommittingData(last writer wins). The handler writes the resolved value here.
The default resolution (before the handler runs) is "last writer wins": the committing data is copied into ToCommitData.
The handler can override this by writing a different value (e.g., rebasing a delta onto the latest committed state).
Properties
ComponentDefinition
The component definition with field metadata.
public DBComponentDefinition ComponentDefinition { get; }
Property Value
ComponentType
The .NET type of the component (e.g. typeof(CompA)).
public Type ComponentType { get; }
Property Value
HasConflict
Whether a conflict was detected for this solver instance.
public bool HasConflict { get; }
Property Value
PrimaryKey
Primary key of the conflicting entity.
public long PrimaryKey { get; }
Property Value
Methods
CommittedData<T>()
Returns a ref to the latest committed state by another transaction (the conflicting value).
public ref T CommittedData<T>() where T : unmanaged
Returns
- T
Type Parameters
T
CommittingData<T>()
Returns a ref to our transaction's dirty-write state (what we intended to commit).
public ref T CommittingData<T>() where T : unmanaged
Returns
- T
Type Parameters
T
ReadData<T>()
Returns a ref to the component state as read by our transaction (snapshot baseline).
public ref T ReadData<T>() where T : unmanaged
Returns
- T
Type Parameters
T
TakeCommitted<T>()
Copies CommittedData<T>() into ToCommitData<T>() (accept the other transaction's value).
public void TakeCommitted<T>() where T : unmanaged
Type Parameters
T
TakeCommitting<T>()
Copies CommittingData<T>() into ToCommitData<T>() (last writer wins — this is the default).
public void TakeCommitting<T>() where T : unmanaged
Type Parameters
T
TakeRead<T>()
Copies ReadData<T>() into ToCommitData<T>() (discard all changes, revert to read snapshot).
public void TakeRead<T>() where T : unmanaged
Type Parameters
T
ToCommitData<T>()
Returns a ref to the output buffer. Write the resolved value here. Initialized with CommittingData<T>().
public ref T ToCommitData<T>() where T : unmanaged
Returns
- T
Type Parameters
T