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: can't Push if head_ overflow? #40

Closed
esrrhs opened this issue Sep 18, 2023 · 3 comments
Closed

BUG: can't Push if head_ overflow? #40

esrrhs opened this issue Sep 18, 2023 · 3 comments

Comments

@esrrhs
Copy link

esrrhs commented Sep 18, 2023

I read the code, and found if the head_ overflow, then it can't Push anymore.
and I change the head_ type from size_t to uint16_t, and just run code:

MPMCQueue<size_t> mp(1024);
for (size_t i = 0; i < UINT64_MAX; ++i) {
    mp.push(i);
    size_t j = 0;
    if (!mp.try_pop(j)) {
        std::cout << "failed " << i << std::endl;
        break;
    }
    std::cout << "success " << i << std::endl;
}

and then it stop cout at 65535 and then dead

success 65533
success 65534
success 65535
@esrrhs
Copy link
Author

esrrhs commented Sep 18, 2023

so if I use the queue a long time, the size_t will has the same problem. or this is just ok? because the time may be very long?

@esrrhs
Copy link
Author

esrrhs commented Sep 18, 2023

I run a test at my computer, found there will be thousand of years to make the size_t overflow. okay, I should not consider that situation :)

@esrrhs esrrhs closed this as completed Sep 18, 2023
@rigtorp
Copy link
Owner

rigtorp commented Sep 18, 2023 via email

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

2 participants