Skip to content

Unable to read remaining values after channel is closed #6

@codeReaper2001

Description

@codeReaper2001
int main() {
    Chan<int> intChan;
    thread t1 = thread([&]() {
        for (int i = 0; i < 10; ++i) {
            intChan << i;
        }
        Close(intChan);
    });

    thread t2 = thread([&]() {
        for(int &x : intChan) {
            cout << x << endl;
        }
    });
    t1.join();
    t2.join();
}

the output is:
image
Is this a bug or is my usage incorrect?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions