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

Resource tracking and destruction #633

Merged
merged 14 commits into from
Mar 8, 2015
Merged

Resource tracking and destruction #633

merged 14 commits into from
Mar 8, 2015

Conversation

kvark
Copy link
Member

@kvark kvark commented Mar 7, 2015

Implements automatic management of the resources. Works just like RAII.

Closes #288, #617

User API changes:

  • there is no such thing as factory.delete_something() any more!
  • Renderer and Factory accept all handles by reference to avoid cloning
  • handles are no longer copyable. That added a bit of noise to the deferred example, but I'm sure we can refactor the interface to solve it.
  • Factory works with RawBuffer type natively now instead of Buffer<()>
  • need to call device.after_frame() after glfw.swap_buffers()

TODO:

@bvssvni
Copy link
Contributor

bvssvni commented Mar 7, 2015

Nice!

@ghost
Copy link

ghost commented Mar 7, 2015

Looks good so far.

use alloc::arc::{strong_count, weak_count};
use std::ops::Deref;
vector.retain(|v| {
strong_count(v) > 1 || weak_count(v) > 1 || {
Copy link

Choose a reason for hiding this comment

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

can we just use an if? this is a bit to tricky.

let free = !(strong_count(v) > 1 || weak_count(v) > 1);
if free { fun(param, v.deref()); }
!free

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, will fix in a moment

@kvark kvark changed the title [WIP] Resource tracking and destruction Resource tracking and destruction Mar 8, 2015
@ghost
Copy link

ghost commented Mar 8, 2015

LGTM, but I would like @bjz or @bvssvni to take a look too.

@bvssvni
Copy link
Contributor

bvssvni commented Mar 8, 2015

Looks good.

@bvssvni
Copy link
Contributor

bvssvni commented Mar 8, 2015

Is this still blocked?

@kvark
Copy link
Member Author

kvark commented Mar 8, 2015

No, I forgot to change the issue status. It's all ready.

Regards,
Dzmitry

On Mar 8, 2015, at 6:23, Sven Nilsen notifications@github.com wrote:

Is this still blocked?


Reply to this email directly or view it on GitHub.

@bvssvni
Copy link
Contributor

bvssvni commented Mar 8, 2015

Ok, I'll merge!

bvssvni added a commit that referenced this pull request Mar 8, 2015
Resource tracking and destruction
@bvssvni bvssvni merged commit ff213e1 into gfx-rs:master Mar 8, 2015
@kvark kvark deleted the resource branch March 8, 2015 14:03
adamnemecek pushed a commit to adamnemecek/gfx that referenced this pull request Apr 1, 2021
633: Fix build status badge r=grovesNL a=Gordon-F

fix gfx-rs#630 

Co-authored-by: Igor Shaposhnik <Gordon-F@users.noreply.github.com>
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.

Safe and convenient resource destruction
2 participants