pub struct AllocatorService { /* private fields */ }Expand description
Permission to give receivers custom allocators.
The SDK may call an allocator’s free function long after the receiver’s
policy was replaced, so custom allocation needs the NDI runtime to stay
initialized until the process exits: the service is created from a
ProcessLifetimeRuntime. The first service fixes the
AllocatorLimits for the process, and later ones must name the same
limits.
A program that loads this crate as part of a plug-in must also keep that module loaded for as long as the process runs, because the SDK holds pointers to its callbacks.
Implementations§
Source§impl AllocatorService
impl AllocatorService
Sourcepub fn new(
runtime: ProcessLifetimeRuntime,
limits: &AllocatorLimits,
) -> Result<Self>
pub fn new( runtime: ProcessLifetimeRuntime, limits: &AllocatorLimits, ) -> Result<Self>
Enable custom allocation with these process-wide limits.
§Errors
Error::InvalidInput when the limits are
out of range or differ from those of an earlier service.
Error::AllocationFailed when the
bounded lease bookkeeping cannot be reserved.
Sourcepub fn usage(self) -> AllocatorUsage
pub fn usage(self) -> AllocatorUsage
A consistent snapshot of retained storage, active calls and decline counters across the process. Counter updates allocate no storage and run under the same lock that accounts for retained allocations.
Sourcepub fn attach(
self,
receiver: Receiver,
) -> Result<AllocatedReceiver, Rejected<Receiver>>
pub fn attach( self, receiver: Receiver, ) -> Result<AllocatedReceiver, Rejected<Receiver>>
Take a receiver so that its allocators can be set.
§Errors
Returns the receiver, untouched, with
Error::UnsupportedCapability
without an Advanced runtime (or in a build without the Advanced SDK).