Fallible notify using (#790)
On Windows, the most common way to out-of-memory is to fail to commit a page. The current design of the Pal assumes that notify_using always succeeds, thus we have to raise an error if it fails. This changes the specification of notify_using to return a bool, indicating whether the notify succeeded or not. This allows Windows to fail the notification, and then the surrounding code can handle the failure appropriately, such as by throwing an exception or returning the nullptr for the allocation. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
d4c7e01cd7
commit
71e205fe17
@@ -38,9 +38,9 @@ The state for a particular region of memory is set with
|
||||
static void notify_not_using(void* p, size_t size) noexcept;
|
||||
|
||||
template<ZeroMem zero_mem>
|
||||
static void notify_using(void* p, size_t size) noexcept;
|
||||
static bool notify_using(void* p, size_t size) noexcept;
|
||||
|
||||
static void notify_using_readonly(void* p, size_t size) noexcept;
|
||||
static bool notify_using_readonly(void* p, size_t size) noexcept;
|
||||
```
|
||||
These functions notify the system that the range of memory from `p` to `p` +
|
||||
`size` is in the relevant state.
|
||||
@@ -48,6 +48,8 @@ These functions notify the system that the range of memory from `p` to `p` +
|
||||
If the template parameter is set to `YesZero` then `notify_using` must ensure
|
||||
the range is full of zeros.
|
||||
|
||||
The function should return `true` if the memory is now in the requested state, and `false` if it failed to make the memory useable.
|
||||
|
||||
```c++
|
||||
template<bool page_aligned = false>
|
||||
static void zero(void* p, size_t size) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user