Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Enable controlling `concurrency_support` in the C API (#12703)

Alex Crichton0dc25e6db03f
diff --git a/crates/c-api/include/wasmtime/config.h b/crates/c-api/include/wasmtime/config.h
index 978b613c37..01f8b7a4b7 100644
--- a/crates/c-api/include/wasmtime/config.h
+++ b/crates/c-api/include/wasmtime/config.h
@@ -824,6 +824,15 @@ WASM_API_EXTERN void wasmtime_pooling_allocation_strategy_set(
*/
WASMTIME_CONFIG_PROP(void, wasm_component_model, bool)
+/**
+ * \brief Specifies whether support for concurrent execution of WebAssembly is
+ * supported within this store.
+ *
+ * For more information see the Rust documentation at
+ * https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.concurrency_support.
+ */
+WASMTIME_CONFIG_PROP(void, concurrency_support, bool)
+
#endif // WASMTIME_FEATURE_COMPONENT_MODEL
#ifdef __cplusplus
diff --git a/crates/c-api/include/wasmtime/config.hh b/crates/c-api/include/wasmtime/config.hh
index 59d549899d..ff418d1fe4 100644
--- a/crates/c-api/include/wasmtime/config.hh
+++ b/crates/c-api/include/wasmtime/config.hh
@@ -619,6 +619,17 @@ public:
wasmtime_pooling_allocation_strategy_set(ptr.get(), config.capi());
}
#endif // WASMTIME_FEATURE_POOLING_ALLOCATOR
+
+ /**
+ * \brief Specifies whether support for concurrent execution of WebAssembly is
+ * supported within this store.
+ *
+ * For more information see the Rust documentation at
+ * https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.concurrency_support.
+ */
+ void concurrency_support(bool enable) {
+ wasmtime_config_concurrency_support_set(ptr.get(), enable);
+ }
};
} // namespace wasmtime
diff --git a/crates/c-api/src/config.rs b/crates/c-api/src/config.rs
index ea8a42394e..365fd37b4c 100644
--- a/crates/c-api/src/config.rs
+++ b/crates/c-api/src/config.rs
@@ -697,3 +697,8 @@ pub extern "C" fn wasmtime_pooling_allocation_strategy_set(
c.config
.allocation_strategy(InstanceAllocationStrategy::Pooling(pc.config.clone()));
}
+
+#[unsafe(no_mangle)]
+pub extern "C" fn wasmtime_config_concurrency_support_set(c: &mut wasm_config_t, enable: bool) {
+ c.config.concurrency_support(enable);
+}
diff --git a/crates/c-api/tests/config.cc b/crates/c-api/tests/config.cc
index 1d61d232a8..3637dd4b25 100644
--- a/crates/c-api/tests/config.cc
+++ b/crates/c-api/tests/config.cc
@@ -69,6 +69,7 @@ TEST(Config, Smoke) {
config.cranelift_flag_set("foo", "bar");
EXPECT_TRUE(config.cache_load_default());
EXPECT_FALSE(config.cache_load("nonexistent"));
+ config.concurrency_support(false);
PoolAllocationConfig pooling_config;
config.pooling_allocation_strategy(pooling_config);