#include <mutex>
#include <condition_variable>
#include <queue>

class Semaphor
{
private:
    int count;
    std::mutex mtx;
    std::condition_variable cond;
    std::queue<std::thread::id> wait_queue; // Beispielhafte Warteschlange

public:
    Semaphor(int i) : count(i) {}

    void acquire()
    {
        std::unique_lock<std::mutex> lock(mtx);
        while (count == 0)
        { // Solange keine Ressourcen verfügbar sind, warten
            cond.wait(lock);
        }
        count--; // Ressource belegen
    }

    void release()
    {
        std::unique_lock<std::mutex> lock(mtx);
        count++;           // Ressource freigeben
        cond.notify_one(); // Einen wartenden Thread aufwecken
    }
};