I don’t see a way to get the maximum capacity of a bounded buffer in apache’s commons? Specifically, I’m using BoundedFifoBuffer. How do you query it for it’s capacity??
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You have to specify the size to the constructor. If you do not specify the size, it is 32.
A quick glance at a source code suggests there is no limit to how large the specified size can be (other than the limit on an
inthaving to be<= Integer.MAX_VALUE = 2^31-1). The only check in the constructor is for the size to be> 0.There is also the practical limit of the amount of free memory you can allocate.
It’s not clear why, but there really is no method for querying the capacity of the buffer. (Presumably if you’re adding elements ignorantly of the capacity you should catch
BufferOverflowExceptionto detect when you’ve reached the capacity.)