Move common dequeue error handling into Queue::dequeue_loop

Change-Id: I991373f805d0a768d60cd4addfcddd68a144d886
Merge "Move common dequeue error handling into Queue::dequeue_loop"