Skip to content

feature for supporting arena allocators #222

@GummyGun

Description

@GummyGun

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions