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 handle to an instance acquired from an InstancePool.

Holds the fresh instance and frees its concurrency slot on drop (dropping the instance — never recycling it). Adapters use this to make “acquire-call-drop” exception-safe: if the plugin call panics or traps, the slot still frees and the (possibly poisoned) instance is discarded.

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 without freeing its concurrency slot via the pool.

Retained for API compatibility. With per-invoke instances there is no “corrupted vs clean” distinction at the pool level (a dropped instance is always discarded), but take still moves the instance out and decrements the live counter so callers that need ownership keep working.

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.