Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in Producer #3

Open
enverunal opened this issue Dec 7, 2024 · 0 comments
Open

Bug in Producer #3

enverunal opened this issue Dec 7, 2024 · 0 comments

Comments

@enverunal
Copy link

void Producer::onData(const std::string& data) {
    long sequence = sequencer_->next(); // ???
    Event& event = ringBuffer_->get(sequence);
    event.set(data);
    sequencer_->publish(sequence);
    std::cout << "[Producer] Published: " << data << " at sequence: " << sequence << "\n";

}

sequencer_->next() increases the cursor position before writing the event. At this point if consumer thread makes a read, it will read unassigned event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant