pub struct FailEveryNth { /* private fields */ }Expand description
Policy that fails every period-th allocation and permits the rest.
Models intermittent OOM (transient pressure): with period = 3,
allocations 3, 6, 9, … fail and the rest succeed. Stateful — the
call counter is an AtomicUsize, so the policy is Send + Sync.
Implementations§
Source§impl FailEveryNth
impl FailEveryNth
Sourcepub const fn new(period: usize) -> FailEveryNth
pub const fn new(period: usize) -> FailEveryNth
Construct a policy that fails every period-th allocation.
§Panics
Panics if period == 0. A period of 1 fails every allocation
(equivalent to AlwaysFail).
Trait Implementations§
Source§impl AllocFaultPolicy for FailEveryNth
impl AllocFaultPolicy for FailEveryNth
Source§fn should_fail(&self, _layout: NonZeroLayout) -> bool
fn should_fail(&self, _layout: NonZeroLayout) -> bool
Return
true to force the pending allocation of layout to
fail with AllocError; return false to
let it proceed to the inner allocator. Read moreAuto Trait Implementations§
impl !Freeze for FailEveryNth
impl RefUnwindSafe for FailEveryNth
impl Send for FailEveryNth
impl Sync for FailEveryNth
impl Unpin for FailEveryNth
impl UnsafeUnpin for FailEveryNth
impl UnwindSafe for FailEveryNth
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