示例#1
0
文件: Deque.cs 项目: Erhannis/Jibu
 //This is only thread safe when called from the thread that owns the Deque.
 public void Push(T w)
 {
     if (!deque.Push(w))
     {
         DequeFixed <T> old   = deque;
         DequeFixed <T> other = new DequeFixed <T>(CalculateNewCapacity(deque));
         deque = other;
         MoveElements(old, other);
         other.Push(w);
     }
 }
示例#2
0
文件: Deque.cs 项目: Erhannis/Jibu
 static private void MoveElements(DequeFixed <T> old, DequeFixed <T> cur)
 {
     while (true)
     {
         T move = old.Steal();
         if (move == null)
         {
             break;
         }
         else
         {
             cur.Push(move);
         }
     }
 }