Refactor configuration for the pooling allocator (#5205)
This commit changes the APIs in the `wasmtime` crate for configuring the pooling allocator. I plan on adding a few more configuration options in the near future and the current structure was feeling unwieldy for adding these new abstractions. The previous `struct`-based API has been replaced with a builder-style API in a similar shape as to `Config`. This is done to help make it easier to add more configuration options in the future through adding more methods as opposed to adding more field which could break prior initializations.
This commit is contained in:
@@ -354,17 +354,13 @@ async fn fuel_eventually_finishes() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn async_with_pooling_stacks() {
|
||||
let mut pool = PoolingAllocationConfig::default();
|
||||
pool.instance_count(1)
|
||||
.instance_memory_pages(1)
|
||||
.instance_table_elements(0);
|
||||
let mut config = Config::new();
|
||||
config.async_support(true);
|
||||
config.allocation_strategy(InstanceAllocationStrategy::Pooling {
|
||||
strategy: PoolingAllocationStrategy::NextAvailable,
|
||||
instance_limits: InstanceLimits {
|
||||
count: 1,
|
||||
memory_pages: 1,
|
||||
table_elements: 0,
|
||||
..Default::default()
|
||||
},
|
||||
});
|
||||
config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool));
|
||||
config.dynamic_memory_guard_size(0);
|
||||
config.static_memory_guard_size(0);
|
||||
config.static_memory_maximum_size(65536);
|
||||
@@ -383,17 +379,14 @@ async fn async_with_pooling_stacks() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn async_host_func_with_pooling_stacks() -> Result<()> {
|
||||
let mut pooling = PoolingAllocationConfig::default();
|
||||
pooling
|
||||
.instance_count(1)
|
||||
.instance_memory_pages(1)
|
||||
.instance_table_elements(0);
|
||||
let mut config = Config::new();
|
||||
config.async_support(true);
|
||||
config.allocation_strategy(InstanceAllocationStrategy::Pooling {
|
||||
strategy: PoolingAllocationStrategy::NextAvailable,
|
||||
instance_limits: InstanceLimits {
|
||||
count: 1,
|
||||
memory_pages: 1,
|
||||
table_elements: 0,
|
||||
..Default::default()
|
||||
},
|
||||
});
|
||||
config.allocation_strategy(InstanceAllocationStrategy::Pooling(pooling));
|
||||
config.dynamic_memory_guard_size(0);
|
||||
config.static_memory_guard_size(0);
|
||||
config.static_memory_maximum_size(65536);
|
||||
|
||||
Reference in New Issue
Block a user