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

WIP: Adding reserve() and capability() feature likes std::vector<> #43

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hizukiayaka
Copy link

MR for #22

Since our minimal requirement is c++14, we have the helper
type std::enable_if_t.

Signed-off-by: Randy Li <ayaka@soulik.info>

constexpr void reserve (std::size_t new_cap)
{
std::list<value_ptr> pending_resources;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I could use std::deque<> here, since we don't need to any random access.

}

m_max_capacity = new_cap;
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would have a critical section here. The return of capacity() and unused_free() won't match.
Besides, while we recycle buffer here, the second thread which calls the pool->allocate() may break the atomic.
Should I use the thread-local lock here, we need make a rule which thread calls reserve(), which thread can allocate().

We can pre-allocate the need elements.

Signed-off-by: Randy Li <ayaka@soulik.info>
Signed-off-by: Randy Li <ayaka@soulik.info>
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 this pull request may close these issues.

1 participant