pub struct Pool { /* private fields */ }Expand description
Pool manages threadsafe access to a limited number of instances of multiple plugins
Implementations§
Source§impl Pool
impl Pool
Sourcepub fn new<F: 'static + Fn() -> Result<Plugin, Error> + Send + Sync>(
source: F,
) -> Self
pub fn new<F: 'static + Fn() -> Result<Plugin, Error> + Send + Sync>( source: F, ) -> Self
Create a new pool with the default configuration
Sourcepub fn new_from_builder<F: 'static + Fn() -> Result<Plugin, Error> + Send + Sync>(
source: F,
builder: PoolBuilder,
) -> Self
pub fn new_from_builder<F: 'static + Fn() -> Result<Plugin, Error> + Send + Sync>( source: F, builder: PoolBuilder, ) -> Self
Create a new pool configured using a PoolBuilder
Sourcepub fn count(&self) -> usize
pub fn count(&self) -> usize
Get the number of live instances for a plugin (both checked out and available)
Sourcepub fn get(&self, timeout: Duration) -> Result<Option<PoolPlugin>, Error>
pub fn get(&self, timeout: Duration) -> Result<Option<PoolPlugin>, Error>
Get access to a plugin, this will create a new instance if needed (and allowed by the specified
max_instances). Ok(None) is returned if the timeout is reached before an available plugin could be
acquired
Sourcepub fn with_plugin<T>(
&self,
timeout: Duration,
f: impl FnOnce(&mut Plugin) -> Result<T, Error>,
) -> Result<Option<T>, Error>
pub fn with_plugin<T>( &self, timeout: Duration, f: impl FnOnce(&mut Plugin) -> Result<T, Error>, ) -> Result<Option<T>, Error>
Access a plugin in a callback function. This calls Pool::get then the provided callback. Ok(None)
is returned if the timeout is reached before an available plugin could be acquired
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pool
impl RefUnwindSafe for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl UnsafeUnpin for Pool
impl UnwindSafe for Pool
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
Set the “status” flags for the
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more