From e7f284052e579ac349d05f61710ff30b14c59f44 Mon Sep 17 00:00:00 2001 From: Marc Hernandez Date: Tue, 22 Jun 2021 13:56:38 -0700 Subject: [PATCH] Whitespace changes --- db/DB.cs | 104 +++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/db/DB.cs b/db/DB.cs index 08a38b2..55074a2 100644 --- a/db/DB.cs +++ b/db/DB.cs @@ -1,16 +1,16 @@ -using System; -using System.Collections.Immutable; +using System; +using System.Collections.Immutable; using Optional; using static Optional.OptionExtensions; -using static System.Collections.Immutable.ImmutableInterlocked; - -/* +using static System.Collections.Immutable.ImmutableInterlocked; + +/* ???? Should we have an explicit transaction class/ID? - ???? Should we split things into threaded vs action -*/ - -namespace db -{ + ???? Should we split things into threaded vs action +*/ + +namespace db +{ public enum CommitResults { @@ -24,9 +24,9 @@ namespace db TS id { get; } } - public class DB where T : IID + public class DB where T : IID { - //Current snapshot of the DB. + //Current snapshot of the DB. ImmutableDictionary m_objs = ImmutableDictionary.Empty; //List of committed Ids based on when they were committed. @@ -35,23 +35,23 @@ namespace db ImmutableDictionary Objects => m_objs; // @@@@ TODO This returns an entity that can be changing. It should be a lazy instantiated copy - public Option lookup( TID id ) - { - if( m_objs.TryGetValue( id, out T obj ) ) + public Option lookup( TID id ) + { + if( m_objs.TryGetValue( id, out T obj ) ) { - return obj.Some(); - } - else + return obj.Some(); + } + else { // LOG - } - - return obj.None(); - } - - public (Tx, Option) checkout( TID id ) + } + + return obj.None(); + } + + public (Tx, Option) checkout( TID id ) { - var tx = new Tx( m_committed.Count, m_activeTransaction, this ); + var tx = new Tx( m_committed.Count, m_activeTransaction, this ); var v = lookup( id ); @@ -59,27 +59,27 @@ namespace db tx.checkout( id ); }, () => { } ); - - return (tx, v); - } - - public Tx checkout( TID id, out Option tOut ) + + return (tx, v); + } + + public Tx checkout( TID id, out Option tOut ) { var (tx, v) = checkout(id); tOut = v; return tx; - } - - public Tx checkout() + } + + public Tx checkout() { - var tx = new Tx( m_committed.Count, m_activeTransaction, this ); + var tx = new Tx( m_committed.Count, m_activeTransaction, this ); - return tx; - } + return tx; + } - public CommitResults commit( ref Tx co ) + public CommitResults commit( ref Tx co ) { co = null; return commit_internal_single( co ); @@ -92,7 +92,7 @@ namespace db } - internal CommitResults commit_internal_single( Tx tx ) + internal CommitResults commit_internal_single( Tx tx ) { //var collision = false; @@ -140,8 +140,8 @@ namespace db - Option> m_activeTransaction = Option.None>(); - + Option> m_activeTransaction = Option.None>(); + } public enum TxStates @@ -153,9 +153,9 @@ namespace db //This only works for a single thread - public class Tx: IDisposable where T : IID - { - internal ImmutableList Checkouts => m_checkouts; + public class Tx: IDisposable where T : IID + { + internal ImmutableList Checkouts => m_checkouts; internal TxStates State => m_state; internal int Start => m_start; internal ImmutableList Adds => m_adds; @@ -191,33 +191,33 @@ namespace db } } - public Option checkout( TID id ) + public Option checkout( TID id ) { var v = m_db.lookup( id ); v.MatchSome( t => { m_checkouts = m_checkouts.Add( t ); } ); return v; - } + } - public void add( T obj ) + public void add( T obj ) { m_adds = m_adds.Add(obj); - } + } - int m_start = -1; + int m_start = -1; DB m_db; //Do we need these? Do we need both? Option> m_parentTx; ImmutableList> m_childTx = ImmutableList>.Empty; - - TxStates m_state = TxStates.Invalid; + + TxStates m_state = TxStates.Invalid; ImmutableList m_checkouts = ImmutableList.Empty; // New objects created this pass - ImmutableList m_adds = ImmutableList.Empty; + ImmutableList m_adds = ImmutableList.Empty; } -} +}