Skip to main content

PooledInstance

Struct PooledInstance 

Source
pub struct PooledInstance<T, E>
where T: Send + 'static, E: PoolResourceLimit + Send + Sync + 'static,
{ /* private fields */ }
Expand description

RAII wrapper acquired from an InstancePool: holds the instance and returns it to the pool on drop.

Adapters use this to make “acquire-call-release” exception-safe — if the plugin call panics, the instance still returns home (drop runs).

Implementations§

Source§

impl<T, E> PooledInstance<T, E>
where T: Send + 'static, E: PoolResourceLimit + Send + Sync + 'static,

Source

pub fn acquire(pool: Arc<InstancePool<T, E>>) -> Result<Self, E>

Acquire a fresh PooledInstance from the pool.

§Errors

Propagates InstancePool::acquire.

Source

pub fn get_mut(&mut self) -> &mut T

Mutable access to the instance.

§Panics

If called after Self::take.

Source

pub fn take(self) -> T

Consume the wrapper, returning the inner instance and not releasing it to the pool. Use this if the instance is known to be corrupted (e.g., trapped on epoch interrupt).

Trait Implementations§

Source§

impl<T, E> Debug for PooledInstance<T, E>
where T: Send + 'static, E: PoolResourceLimit + Send + Sync + 'static,

Source§

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

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

impl<T, E> Drop for PooledInstance<T, E>
where T: Send + 'static, E: PoolResourceLimit + Send + Sync + 'static,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<T, E> !RefUnwindSafe for PooledInstance<T, E>

§

impl<T, E> !UnwindSafe for PooledInstance<T, E>

§

impl<T, E> Freeze for PooledInstance<T, E>
where T: Freeze,

§

impl<T, E> Send for PooledInstance<T, E>

§

impl<T, E> Sync for PooledInstance<T, E>
where T: Sync,

§

impl<T, E> Unpin for PooledInstance<T, E>
where T: Unpin,

§

impl<T, E> UnsafeUnpin for PooledInstance<T, E>
where T: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.