pub struct MemoryGuardBuilder { /* private fields */ }Expand description
Builder for MemoryGuard.
let device = Arc::new(GpuDevice::new(0).unwrap());
let guard = MemoryGuardBuilder::new(device)
.budget_bytes(16 * 1024 * 1024 * 1024)
.reserve_bytes(16 * 1024 * 1024 * 1024)
.oom_policy(OomPolicy::RetryAfterFree)
.build()
.unwrap();Implementations§
Source§impl MemoryGuardBuilder
impl MemoryGuardBuilder
Sourcepub fn budget_bytes(self, bytes: usize) -> Self
pub fn budget_bytes(self, bytes: usize) -> Self
Set the hard memory budget in bytes. 0 means unlimited.
Sourcepub fn reserve_bytes(self, bytes: usize) -> Self
pub fn reserve_bytes(self, bytes: usize) -> Self
Pre-allocate bytes of VRAM as a reservation sentinel.
Other processes cannot use this memory while the guard is alive.
Sourcepub fn oom_policy(self, policy: OomPolicy) -> Self
pub fn oom_policy(self, policy: OomPolicy) -> Self
Set the OOM recovery policy.
Sourcepub fn build(self) -> GpuResult<MemoryGuard>
pub fn build(self) -> GpuResult<MemoryGuard>
Build the MemoryGuard.
If reserve_bytes was set, this will attempt to allocate the
sentinel buffer. Failure to allocate is returned as an error.
Auto Trait Implementations§
impl Freeze for MemoryGuardBuilder
impl RefUnwindSafe for MemoryGuardBuilder
impl Send for MemoryGuardBuilder
impl Sync for MemoryGuardBuilder
impl Unpin for MemoryGuardBuilder
impl UnsafeUnpin for MemoryGuardBuilder
impl UnwindSafe for MemoryGuardBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more