pub struct SharedRunspacePool<T: PsrpTransport> { /* private fields */ }Expand description
Clone-able handle to a RunspacePool.
Every method acquires an internal mutex before calling into the
underlying pool, so callers can safely share a SharedRunspacePool
across tasks.
Implementations§
Sourcepub fn new(pool: RunspacePool<T>) -> Self
pub fn new(pool: RunspacePool<T>) -> Self
Wrap an already-opened RunspacePool.
Sourcepub fn handle_count(&self) -> usize
pub fn handle_count(&self) -> usize
Number of outstanding handles to the same pool.
Sourcepub async fn run_script(&self, script: &str) -> Result<Vec<PsValue>>
pub async fn run_script(&self, script: &str) -> Result<Vec<PsValue>>
Run a script. Acquires the mutex for the whole call.
Sourcepub async fn run_pipeline(&self, pipeline: Pipeline) -> Result<PipelineResult>
pub async fn run_pipeline(&self, pipeline: Pipeline) -> Result<PipelineResult>
Run a pre-built Pipeline and collect every stream.
Sourcepub async fn run_script_with_cancel(
&self,
script: &str,
cancel: CancellationToken,
) -> Result<Vec<PsValue>>
pub async fn run_script_with_cancel( &self, script: &str, cancel: CancellationToken, ) -> Result<Vec<PsValue>>
Run a script with a cancellation token.
Sourcepub async fn request_session_key(&self) -> Result<()>
pub async fn request_session_key(&self) -> Result<()>
Request a session key for SecureString transport.
Sourcepub async fn close(self) -> Result<()>
pub async fn close(self) -> Result<()>
Close the pool. Only the last outstanding handle can actually close — if other clones are still alive, returns an error wrapping the still-contended pool.
Sourcepub async fn with_pool<F, R>(&self, f: F) -> R
pub async fn with_pool<F, R>(&self, f: F) -> R
Acquire the pool mutex and run a closure with direct access to
the underlying RunspacePool. Useful when you need an API
that isn’t surfaced on the shared wrapper.