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

adding support to object construction with arguments. #259

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

Conversation

tinebp
Copy link

@tinebp tinebp commented Oct 23, 2023

No description provided.

Copy link
Member

@ben-clayton ben-clayton left a comment

Choose a reason for hiding this comment

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

Thank you for your PR. A couple of changes requested.

include/marl/pool.h Outdated Show resolved Hide resolved
include/marl/pool.h Show resolved Hide resolved
MARL_NO_EXPORT inline void borrow(size_t count, const F& f) const;
template <typename F, typename... Args>
MARL_NO_EXPORT inline void borrowList(size_t count, const F& f, Args&&... args) const {
marl::lock lock(storage->mutex);
Copy link
Member

Choose a reason for hiding this comment

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

Please also add the static_assert here.

MARL_NO_EXPORT inline std::pair<Loan, bool> tryBorrow() const;
template <typename... Args>
MARL_NO_EXPORT inline std::pair<Loan, bool> tryBorrow(Args&&... args) const {
Item* item = nullptr;
Copy link
Member

Choose a reason for hiding this comment

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

And here

@@ -214,32 +212,65 @@ class BoundedPool : public Pool<T> {

// borrow() borrows a single item from the pool, blocking until an item is
// returned if the pool is empty.
MARL_NO_EXPORT inline Loan borrow() const;
template <typename... Args>
MARL_NO_EXPORT inline Loan borrow(Args&&... args) const {
Copy link
Member

Choose a reason for hiding this comment

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

Any reason you've inlined these methods into the class? Marl tries to keep the implementations out of the class, so the public interface is easily human parsable. I'd prefer it if these were put back where they were.

@@ -366,11 +355,6 @@ class UnboundedPool : public Pool<T> {
MARL_NO_EXPORT inline Storage(Allocator* allocator);
MARL_NO_EXPORT inline ~Storage();
MARL_NO_EXPORT inline void return_(Item*) override;
// We cannot copy this as the Item pointers would be shared and
Copy link
Member

Choose a reason for hiding this comment

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

While I see you've moved this up to Storage, I think it would be generally safer if this remained here as well. Please revert.

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.

None yet

2 participants