Example #1
0
 public void Push(object o)
 {
     mut.WaitOne();
     if (tail == null)
     {
         InitFromEmpty(o);
     }
     else
     {
         DLLNode new_tail = new DLLNode(o);
         tail.next     = new_tail;
         new_tail.prev = tail;
         tail          = new_tail;
     }
     mut.ReleaseMutex();
 }
Example #2
0
 public void PushFront(object o)
 {
     mut.WaitOne();
     if (head == null)
     {
         InitFromEmpty(o);
     }
     else
     {
         DLLNode new_head = new DLLNode(o);
         new_head.next = head;
         head.prev     = new_head;
         head          = new_head;
     }
     mut.ReleaseMutex();
 }
Example #3
0
 public object?Pop()
 {
     mut.WaitOne();
     if (head == null)
     {
         mut.ReleaseMutex();
         return(null);
     }
     else
     {
         DLLNode popped = head;
         head = head.next;
         if (head != null)
         {
             head.prev = null;
         }
         else
         {
             tail = null;
         }
         mut.ReleaseMutex();
         return(popped.data);
     }
 }
Example #4
0
 public object?PopBack()
 {
     mut.WaitOne();
     if (tail == null)
     {
         mut.ReleaseMutex();
         return(null);
     }
     else
     {
         DLLNode popped = tail;
         tail = popped.prev;
         if (tail != null)
         {
             tail.next = null;
         }
         else
         {
             head = null;
         }
         mut.ReleaseMutex();
         return(popped.data);
     }
 }