#pragma once

#include "queue.hpp"
#include <string>
#include <vector>
#include <thread>
#include <chrono>
#include <print>
#include <fstream>

namespace workers {
    void producer(ipc::queue& q, const std::vector<std::string>& files) {
        for (const auto& file : files) {
            std::this_thread::sleep_for(std::chrono::milliseconds(100));
            q.push(file);
            std::print("Produced: {}\n", file);
        }
    }

    void consumer(ipc::queue& queue) {
        while (true) {
            std::string path;
            if (!queue.pop(path)) continue;

            if (path == "__DONE__") break;

            std::ifstream file(path);
            std::print("Consumed: {}\n", path);
            for (std::string line; std::getline(file, line);) {
                std::print("\t{}\n", line);
            }
        }
    }
}