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

grant_max does not reserve the largest contiguous buffer available #29

Closed
jonas-schievink opened this issue Aug 7, 2019 · 1 comment

Comments

@jonas-schievink
Copy link
Contributor

jonas-schievink commented Aug 7, 2019

This might just be a documentation issue, but I was assuming that grant_max should behave identically to grant wrt. the successful case. An example:

use bbqueue::*;

fn main() {
    let bbq = bbq!(1000).unwrap();

    let size = 999;
    let grant = bbq.grant(size).unwrap();
    bbq.commit(size, grant);
    let grant = bbq.read().unwrap();
    bbq.release(size, grant);

    let grant = bbq.grant_max(500).unwrap();
    println!("{}", grant.len());
    bbq.commit(0, grant);
}

This consumes and then frees all but 1 Byte of the queue. Then it tries to obtain a 500-byte grant using grant_max. I would expect this to succeed and return the requested 500-byte grant, since there's a large 999-byte area that's still free. Instead it returns a grant of length 1.

Using grant instead will successfully grant 500 bytes.

@jamesmunns
Copy link
Owner

The docs have been updated in #37, and work on new grant types is tracked in #38.

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

Successfully merging a pull request may close this issue.

2 participants