Cbeam
|
Manages delayed deallocation of memory blocks in shared library contexts. More...
#include <stable_reference_buffer.hpp>
Public Member Functions | |
delay_deallocation () | |
Begin a scope that prevents deallocation of memory created within it. | |
~delay_deallocation () noexcept | |
Exit the protected scope, potentially leading to deallocation of memory. | |
Manages delayed deallocation of memory blocks in shared library contexts.
Ensures that memory blocks remain valid even if their reference count drops to zero within the scope of this class. This capability is critical when shared libraries need to pass raw pointers back and forth, especially in cases where a library might be unloaded, but the memory it allocated is still in use. The stable_reference_buffer::safe_get()
method complements this by safely retrieving raw pointers, ensuring that they are valid within the delay_deallocation
scope, and returning nullptr
if not to prevent unsafe access.
delay_deallocation
scope, allowing safe pointer access.stable_reference_buffer
instances are destructed, especially critical in scenarios involving the unloading of shared libraries.DelayDeallocationTest
for practical implementations.delay_deallocation
where stable_reference_buffer
raw pointers are needed, especially when the original buffer instance may have been destructed.stable_reference_buffer::safe_get()
for secure pointer retrieval, ensuring it's within an active delay_deallocation
scope.
|
inline |
Begin a scope that prevents deallocation of memory created within it.
|
inlinenoexcept |
Exit the protected scope, potentially leading to deallocation of memory.