implement a version of queue_pop which utilizes pthread_cond_wait if the
queue is currently empty.