-
Notifications
You must be signed in to change notification settings - Fork 193
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
No description provided.