#include "../include/render/task.h"
#include <mutex>
#include <queue>

namespace {
unsigned int g_curID{0};
std::mutex mtx_cmdQueue{};
std::queue<Z::Task> q_command{};
}

void Z::Task::AddCommand(Task &task) noexcept {
    std::lock_guard lk(mtx_cmdQueue);
    task.id = g_curID++;
    q_command.push(task);
}
bool Z::Task::TryGetCommand(Task &task) {
    std::lock_guard lk(mtx_cmdQueue);
    if (q_command.empty())return false;
    task = q_command.front();
    q_command.pop();
    return true;
}
