-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Just a random idea.
Lets consider a developer using an exception block allocator like so:
std::array<exception_header<SizeOfLargestException>, NumberOfThreads * 2> m_exception_memory{};
std::pmr::montonic_memory_resource exception_memory(m_exception_memory.data(), std::as_bytes(m_exception_memory).size());Lets assume we have a way to acquiring the value SizeOfLargestException from the compiler and NumberOfThreads from the application. With this, you'll always have storage for 2 exception objects for each thread. 2 are needed because there may be a throw E expression in a catch block which requires additional storage as the caught exception needs to outlive the current scope.
In this case, you may have an thrown object that doesn't take up SizeOfLargestException of space. Meaning if that object wants to perform an allocation, we could allocate the memory from the left over space within the block. It could be acquired via hal::get_remaining_exception_allocator_memory. (I know, I know, very long name)