Admit shared readers up to a fixed pool and report whether a writer could still run.

Reader Pool Coordination Report

reader_pool_coordination_report.cpp
#include <atomic>
#include <iostream>
#include <string>

int main() {
    int readers = ;
    const int capacity = 3;
    std::atomic<int> active{0};
    int held = 0;

    for (int i = 0; i < readers; ++i) {
        if (active.load() < capacity) {
            active.fetch_add(1);
            held += 1;
        }
    }

    int idle = capacity - held;

    std::string status;
    if (held == 0) {
        status = "writable";
    } else if (held == 1) {
        status = "single";
    } else {
        status = "shared";
    }

    std::cout << "readers=" << readers
              << " held=" << held
              << " free=" << idle
              << " " << status << std::endl;
    return 0;
}
#include <atomic>
#include <iostream>
#include <string>

int main() {
    int readers = ;
    const int capacity = 3;
    std::atomic<int> active{0};
    int held = 0;

    for (int i = 0; i < readers; ++i) {
        if (active.load() < capacity) {
            active.fetch_add(1);
            held += 1;
        }
    }

    int idle = capacity - held;

    std::string status;
    if (held == 0) {
        status = "writable";
    } else if (held == 1) {
        status = "single";
    } else {
        status = "shared";
    }

    std::cout << "readers=" << readers
              << " held=" << held
              << " free=" << idle
              << " " << status << std::endl;
    return 0;
}
#include <atomic>
#include <iostream>
#include <string>

int main() {
    int readers = ;
    const int capacity = 3;
    std::atomic<int> active{0};
    int held = 0;

    for (int i = 0; i < readers; ++i) {
        if (active.load() < capacity) {
            active.fetch_add(1);
            held += 1;
        }
    }

    int idle = capacity - held;

    std::string status;
    if (held == 0) {
        status = "writable";
    } else if (held == 1) {
        status = "single";
    } else {
        status = "shared";
    }

    std::cout << "readers=" << readers
              << " held=" << held
              << " free=" << idle
              << " " << status << std::endl;
    return 0;
}
shared admission count A reader pool admits several shared holders at once but excludes a writer while any reader is active. A `std::atomic<int>` active count is incremented with `fetch_add` for each admitted reader as long as it stays under the pool capacity, so the count is the number of concurrent readers a writer would have to wait behind. Because the increments run in a single deterministic pass with no blocking, the report shows how many slots are held versus free and labels the section writable when empty, single for one reader, or shared for many.