public Task getTaskOrWait() throws InterruptedException {
        // Wait while next task appears in queue
        Task task = queue.take();
        if (isBecomeReady()) {
            EventBusFactory.getDefault().fire(new QueueReadyEvent());
        }
        return task;
    }