1b14551d7SAlex Crichton use super::PoolingAllocationConfig; 2c227063fSAndrew Brown use arbitrary::Arbitrary; 3c227063fSAndrew Brown 4c227063fSAndrew Brown /// Configuration for `wasmtime::InstanceAllocationStrategy`. 5c227063fSAndrew Brown #[derive(Arbitrary, Clone, Debug, Eq, PartialEq, Hash)] 6c227063fSAndrew Brown pub enum InstanceAllocationStrategy { 7c227063fSAndrew Brown /// Use the on-demand instance allocation strategy. 8c227063fSAndrew Brown OnDemand, 9c227063fSAndrew Brown /// Use the pooling instance allocation strategy. 10b14551d7SAlex Crichton Pooling(PoolingAllocationConfig), 11c227063fSAndrew Brown } 12c227063fSAndrew Brown 13c227063fSAndrew Brown impl InstanceAllocationStrategy { 14c227063fSAndrew Brown /// Convert this generated strategy a Wasmtime strategy. configure(&self, cfg: &mut wasmtime_cli_flags::CommonOptions)15*ba4e22bcSAlex Crichton pub fn configure(&self, cfg: &mut wasmtime_cli_flags::CommonOptions) { 16c227063fSAndrew Brown match self { 17*ba4e22bcSAlex Crichton InstanceAllocationStrategy::OnDemand => {} 18b14551d7SAlex Crichton InstanceAllocationStrategy::Pooling(pooling) => { 19*ba4e22bcSAlex Crichton cfg.opts.pooling_allocator = Some(true); 20*ba4e22bcSAlex Crichton pooling.configure(cfg); 21c227063fSAndrew Brown } 22c227063fSAndrew Brown } 23c227063fSAndrew Brown } 24c227063fSAndrew Brown } 25