pub struct SlabPool(/* private fields */);
Expand description
Non-owning wrapper for an ngx_slab_pool_t
pointer, providing methods for working with
shared memory slab pools.
See https://nginx.org/en/docs/dev/development_guide.html#shared_memory.
Implementations§
Source§impl SlabPool
impl SlabPool
Sourcepub unsafe fn from_shm_zone(shm_zone: &ngx_shm_zone_t) -> Option<Self>
pub unsafe fn from_shm_zone(shm_zone: &ngx_shm_zone_t) -> Option<Self>
Creates a new SlabPool
from an initialized shared zone.
§Safety
Shared zones are initialized and safe to use:
- between the zone init callback and configuration reload in the master process
- during the whole lifetime of a worker process.
After the configuration reload (notably, in the cycle pool cleanup handlers), zone addresses in the old cycle may become unmapped.
Sourcepub fn lock(&self) -> LockedSlabPool
pub fn lock(&self) -> LockedSlabPool
Locks the slab pool mutex.
Trait Implementations§
Source§impl Allocator for SlabPool
impl Allocator for SlabPool
Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Attempts to allocate a block of memory. Read more
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
Deallocates the memory referenced by
ptr
. Read moreSource§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Behaves like
allocate
, but also ensures that the returned memory is zero-initialized. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Attempts to extend the memory block. Read more
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Behaves like
grow
, but also ensures that the new contents are set to zero before being
returned. Read moreSource§impl AsMut<ngx_slab_pool_t> for SlabPool
impl AsMut<ngx_slab_pool_t> for SlabPool
Source§fn as_mut(&mut self) -> &mut ngx_slab_pool_t
fn as_mut(&mut self) -> &mut ngx_slab_pool_t
Converts this type into a mutable reference of the (usually inferred) input type.
Source§impl AsRef<ngx_slab_pool_t> for SlabPool
impl AsRef<ngx_slab_pool_t> for SlabPool
Source§fn as_ref(&self) -> &ngx_slab_pool_t
fn as_ref(&self) -> &ngx_slab_pool_t
Converts this type into a shared reference of the (usually inferred) input type.
impl Send for SlabPool
impl Sync for SlabPool
Auto Trait Implementations§
impl Freeze for SlabPool
impl RefUnwindSafe for SlabPool
impl Unpin for SlabPool
impl UnwindSafe for SlabPool
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