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

Return VideoBuffer to VideoBufferPool when shared pointer is destroyed #282

Merged
merged 5 commits into from May 20, 2024

Conversation

murillo128
Copy link
Member

No description provided.

@murillo128
Copy link
Member Author

Current code was just a factory, it didn't return the object to the pool when it was released

pool->enqueue(p);
} else {
//Delete it
delete (buffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be changed to delete p. For example, if the shared_ptr.reset(new VideoBuffer) is called, the deleter should not always try to delete the pointer when the shared_ptr was constructed.

Copy link
Contributor

Choose a reason for hiding this comment

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

other than this, lgtm

Copy link
Member Author

Choose a reason for hiding this comment

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

rigth

//Try to get a reference to the pool, as it may have been already deleted
auto pool = weak.lock();
//Ensure we are not overallocating
if (maxallocate && pool && pool->size_approx() < maxallocate)
Copy link
Contributor

Choose a reason for hiding this comment

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

If pool can go out of scope then can this->maxallocated also be out of scope?

Copy link
Member Author

Choose a reason for hiding this comment

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

right, I thought about this, but not sure why I concluded that the = in the capture was going to make a copy of it. Capturing it explicitly now.

include/VideoBufferPool.h Outdated Show resolved Hide resolved
include/VideoBufferPool.h Outdated Show resolved Hide resolved
Copy link
Contributor

@harryz2000 harryz2000 left a comment

Choose a reason for hiding this comment

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

lgtm

@murillo128 murillo128 merged commit 4dc1903 into master May 20, 2024
2 checks passed
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

3 participants