Make the dequeue function non-blocking. Add a qsize() function.

Change-Id: I89319369601df1a18ee69cecc8d41b5f5ced7a86