pub fn try_decrement(&self, requested: NumBytes) -> Result<(), SubnetAvailableMemoryError> {
        let mut available = self.0.write().unwrap();
        if requested.get() as i64 <= *available {
            *available -= requested.get() as i64;
            Ok(())
        } else {
            Err(SubnetAvailableMemoryError::InsufficientMemory {
                requested,
                available: *available,
            })
        }
    }
/// Try to use some memory capacity and fail if not enough is available
Try to use some memory capacity and fail if not enough is available
Try to use some memory capacity and fail if not enough is available
pub fn try_decrement(&self, requested: NumBytes) -> Result<(), SubnetAvailableMemoryError> {
        let mut available = self.0.write().unwrap();
        if requested.get() as i64 <= *available {
            *available -= requested.get() as i64;
            Ok(())
        } else {
            Err(SubnetAvailableMemoryError::InsufficientMemory {
                requested,
                available: *available,
            })
        }
    }
pub fn try_decrement ( & self , requested : NumBytes ) -> Result < ( ) , SubnetAvailableMemoryError > { let mut available = self . 0 . write ( ) . unwrap ( ) ; if requested . get ( ) as i64 <= * available { * available -= requested . get ( ) as i64 ; Ok ( ( ) ) } else { Err ( SubnetAvailableMemoryError :: InsufficientMemory { requested , available : * available , } ) } }
Try to use some memory capacity and fail if not enough is available
Try to use some memory capacity and fail if not enough is available
&self
requested
NumBytes
&self
requested
NumBytes