Пример #1
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();
            }
        }
Пример #2
0
 /// <summary>
 /// Gets the (immutable) value the reference is holding.
 /// </summary>
 /// <returns>The value</returns>
 public override object deref()
 {
     return(_state.Get());
 }
Пример #3
0
 public Exception getError()
 {
     return(_aq.Get()._error);
 }