Skip to main content

TalcLock

Struct TalcLock 

Source
pub struct TalcLock<R: RawMutex, S: Source, B: Binning> { /* private fields */ }
Expand description

Wraps a mutex-locked Talc.

§Example

use spinning_top::RawSpinlock;

let talc = talc::TalcLock::<RawSpinlock, _>::new(Manual);

Implementations§

Source§

impl<R: RawMutex, S: Source, B: Binning> TalcLock<R, S, B>

Source

pub const fn new(source: S) -> Self

Create a new TalcLock.

Source

pub fn lock(&self) -> MutexGuard<'_, R, Talc<S, B>>

Lock the mutex and access the inner Talc.

Source

pub fn try_lock(&self) -> Option<MutexGuard<'_, R, Talc<S, B>>>

Try to lock the mutex and access the inner Talc.

Source

pub fn get_mut(&mut self) -> &mut Talc<S, B>

Returns a mutable reference to the inner Talc.

This avoids locking, as having a mutable reference statically guarantees that self is not locked.

Source

pub fn into_inner(self) -> Talc<S, B>

Retrieve the inner Talc.

Trait Implementations§

Source§

impl<R: RawMutex, S: Source, B: Binning> Allocator for TalcLock<R, S, B>

Source§

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)

Deallocates the memory referenced by ptr. Read more
Source§

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 more
Source§

fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>

Behaves like allocate, but also ensures that the returned memory is zero-initialized. Read more
Source§

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 shrink( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>

Attempts to shrink the memory block. Read more
Source§

fn by_ref(&self) -> &Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Allocator. Read more
Source§

impl<R: Debug + RawMutex, S: Debug + Source, B: Debug + Binning> Debug for TalcLock<R, S, B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<R: RawMutex, S: Source, B: Binning> GlobalAlloc for TalcLock<R, S, B>

Source§

unsafe fn alloc(&self, layout: Layout) -> *mut u8

Allocates memory as described by the given layout. Read more
Source§

unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)

Deallocates the block of memory at the given ptr pointer with the given layout. Read more
Source§

unsafe fn realloc( &self, ptr: *mut u8, old_layout: Layout, new_size: usize, ) -> *mut u8

Shrinks or grows a block of memory to the given new_size in bytes. The block is described by the given ptr pointer and layout. Read more
1.28.0 · Source§

unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8

Behaves like alloc, but also ensures that the contents are set to zero before being returned. Read more

Auto Trait Implementations§

§

impl<R, S, B> !Freeze for TalcLock<R, S, B>

§

impl<R, S, B> !RefUnwindSafe for TalcLock<R, S, B>

§

impl<R, S, B> Send for TalcLock<R, S, B>
where R: Send, S: Send,

§

impl<R, S, B> Sync for TalcLock<R, S, B>
where R: Sync, S: Send,

§

impl<R, S, B> Unpin for TalcLock<R, S, B>
where R: Unpin, <B as Binning>::AvailabilityBitField: Unpin, S: Unpin,

§

impl<R, S, B> UnsafeUnpin for TalcLock<R, S, B>

§

impl<R, S, B> UnwindSafe for TalcLock<R, S, B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.