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

feature for supporting arena allocators #222

Open
GummyGun opened this issue Apr 21, 2024 · 0 comments
Open

feature for supporting arena allocators #222

GummyGun opened this issue Apr 21, 2024 · 0 comments

Comments

@GummyGun
Copy link

Worth pointing that this is mainly targeted towards the vulkan part of the crate.
I believe that arena al locators are pretty useful specially in graphics(vulkan) when accessing some per level resources.
right now this is kind of hard to with the current API, I have found some workarounds to achieve this style of resource acquisition but I think that it would be a good feature to give to the users of the crate.
first of all, i think that this should be a opt-in since I understand that not all persons have the need for this kind of functionality.
I was thinking of a method, that took Allocation and separated the memory part from a new struct that can be used for freeing the resource. at the same time I think that it would be useful for this functions to implement as well a unsafe_clone, since with arena style allocators resource counting is kind of redundant.

maybe even make the function that splits the Allocator into its parts a method on the Allocator

let my_allocation: Allocation = my_allocator.allocate(...)?; 
let (memory_part, freeing_part) = unsafe{my_allocator.defer_free(my_allocation)};
/*
memory_part can be safely binded to all kinds of resources. 
*/
my_allocator.free(freeing_part);
/*
memory_part shouldn't be accessed from here on out.  
*/

maybe some extra security could be further added in case that it is determined that it is needed.
I hope that this call the attention and get consider for a further addition to this excellent crate, and of course I would be more than pleased to help in any way.

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

No branches or pull requests

1 participant