exec::function cleanup#2089
Open
ispeters wants to merge 13 commits into
Open
Conversation
a4f0e3f to
797d602
Compare
I'm about to write a new algorithm that injects a frame allocator into its child's environment, so I'm going to need to be able to refer to `get_frame_allocator_t` but I don't need to refer to `function` so I'm splitting the declarations.
Also, add an allocator named `__frame_allocator` that's basically `polymorphic_allocator` but knows the concrete type of the `memory_resource*` it uses for allocations.
2bd3c51 to
fb34b06
Compare
Use the new `exec::__fa::__frame_allocator_t` alias template in `exec::function`'s allocator-selection logic, in anticipation of supporting a wider variety of allocators.
With this change, you don't need to add `some_allocator(get_frame_allocator_t)` to the list of type-erased queries for the erased operation to see that its receiver's environment contains a frame allocator. If the list of type-erased queries *does* contain that type, it's preferred, allowing the user to override the return type of `get_frame_allocator` but we otherwise provide a `std::pmr::polymorphic_allocator<std::byte>` that is backed by whichever allocator was actually used to allocate the operation state.
More documentation, a TODO, and IWYU.
This diff brings `function.hpp` in line with the other files that implement `exec::function`-related types by using `_Ugly` and `__ugly` identifiers.
This diff pulls `__memory_resource_adaptor` out of `function.hpp` and into its own header.
This diff includes tests that validate that `__frame_allocator_t<Resource>` correctly does or does not do "uses-allocator" construction, depending on the type of `Resource`, and fixes the implementation to make the tests pass.
This diff implements over-aligned allocations in `exec::__memory_resource_adaptor` and adds test cases proving it works.
fb34b06 to
52b0b0a
Compare
Also delete a redundant `public`.
I keep making plans to collaapse the nested type alias into just a constrained class template only to remember why I can't. This diff adds docs explaining that the nested alias is required so I don't try to get rid of it again.
6ae2691 to
22bc76c
Compare
Collaborator
|
/ok to test 22bc76c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This stack tidies up
exec::functionsome:get_frame_allocatorquery out offunction.hppinto its own header;get_frame_allocatorcan return either anallocator (as it already could) or a
std::pmr::memory_resource*;exec::functionalways see an inheritedframe allocator in their environment, whether the
functionhas aget_frame_allocatorquery in its type-erased environment queries or not; and
function.hppand__uglifiesits identifiers.Still TODO:
__frame_allocatorclass needs to implement "uses-allocator construction" tomatch
std::pmr::polymorphic_allocator<>::construct's behaviour; and__alignarguments to__memory_resource_adaptor'sdo_allocateanddo_deallocatemember functions.