[FIX] fixed some concurrency issues and introduced a popFront() that only if the queue is empty and there is no writer left