/// <summary>
        /// Enqueue an action in the pending queue.
        /// </summary>
        /// <param name="action">The action to enqueue.</param>
        /// <remarks>Spin-locks to update the queue.</remarks>
        void Enqueue(Action action)
        {
            bool queued = false;
            ActionQueue prior = null;
            while (!queued)
            {
                prior = _aq.Get();
                queued = _aq.CompareAndSet(prior, new ActionQueue((IPersistentStack)prior._q.cons(action), prior._error));
            }

            if (prior._q.count() == 0 && prior._error == null )
                action.execute();
        }
Exemple #2
0
        /// <summary>
        /// Enqueue an action in the pending queue.
        /// </summary>
        /// <param name="action">The action to enqueue.</param>
        /// <remarks>Spin-locks to update the queue.</remarks>
        void Enqueue(Action action)
        {
            bool queued = false;
            IPersistentStack prior = null;
            while (!queued)
            {
                prior = _q.Get();
                queued = _q.CompareAndSet(prior, (IPersistentStack)prior.cons(action));
            }

            if (prior.count() == 0)
                action.execute();
        }