HostPoolBuilder

Struct HostPoolBuilder 

Source
pub struct HostPoolBuilder { /* private fields */ }
Expand description

Builder for a HostPool

Implementations§

Source§

impl HostPoolBuilder

Source

pub fn new() -> Self

Instantiate a nnew HostPoolBuilder with default settings.

let builder = HostPoolBuilder::new();
Source

pub fn name<T: AsRef<str>>(self, name: T) -> Self

Set the name for the HostPool.

let builder = HostPoolBuilder::new().name("My Module");
Source

pub fn factory<F>(self, factory: F) -> Self
where F: Fn() -> WapcHost + Send + Sync + 'static,

Set the WapcHost generator function to use when spawning new workers.

let engine = wasmtime_provider::WasmtimeEngineProvider::new(&bytes, None).unwrap();
let pool = HostPoolBuilder::new()
  .factory(move || {
    let engine = engine.clone();
    WapcHost::new(Box::new(engine), None).unwrap()
  })
  .build();
Source

pub fn min_threads(self, min: usize) -> Self

Set the minimum, base number of threads to spawn.

let builder = HostPoolBuilder::new().min_threads(1);
Source

pub fn max_threads(self, max: usize) -> Self

Set the upper limit on the number of threads to spawn.

let builder = HostPoolBuilder::new().max_threads(5);
Source

pub fn max_idle(self, timeout: Duration) -> Self

Set the timeout for threads to self-close.

let builder = HostPoolBuilder::new().max_idle(Duration::from_secs(60));
Source

pub fn max_wait(self, duration: Duration) -> Self

Set the maximum amount of time to wait before spawning a new worker.

let builder = HostPoolBuilder::new().max_wait(Duration::from_millis(100));
Source

pub fn build(self) -> HostPool

Builds a HostPool with the current configuration. Warning: this will panic if a factory function is not supplied.

let engine = wasmtime_provider::WasmtimeEngineProvider::new(&bytes, None).unwrap();
let pool = HostPoolBuilder::new()
  .factory(move || {
    let engine = engine.clone();
    WapcHost::new(Box::new(engine), None).unwrap()
  })
  .build();

Trait Implementations§

Source§

impl Debug for HostPoolBuilder

Source§

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

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

impl Default for HostPoolBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.