GetRunning() static private method

Get the transaction running on this thread (or null if no transaction).
static private GetRunning ( ) : LockingTransaction
return LockingTransaction
Example #1
0
        /// <summary>
        /// Gets the (immutable) value the reference is holding.
        /// </summary>
        /// <returns>The value</returns>
        public override object deref()
        {
            LockingTransaction t = LockingTransaction.GetRunning();

            if (t == null)
            {
                object ret = currentVal();
                //Console.WriteLine("Thr {0}, {1}: No-trans get => {2}", Thread.CurrentThread.ManagedThreadId,DebugStr(), ret);
                return(ret);
            }
            return(t.DoGet(this));
        }
Example #2
0
        /// <summary>
        /// Send an action (encapsulated message).
        /// </summary>
        /// <param name="action">The action to execute.</param>
        /// <remarks>
        /// <para>If there is a transaction running on this thread,
        /// defer execution until the transaction ends
        /// (enqueue the action on the transaction).</para>
        /// <para>If there is already an action running, enqueue it (nested).</para>
        /// <para>Otherwise, queue it for execution.</para>
        /// </remarks>
        internal static void DispatchAction(Action action)
        {
            LockingTransaction trans = LockingTransaction.GetRunning();

            if (trans != null)
            {
                trans.Enqueue(action);
            }
            else if (_nested != null)
            {
                _nested = _nested.cons(action);
            }
            else
            {
                action.Agent.Enqueue(action);
            }
        }