A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
C++ API: Make `wasmtime::Store::gc` return a `Result` (#12439)
Nick Fitzgeraldb34556f9b3a4
diff --git a/crates/c-api/include/wasmtime/store.hh b/crates/c-api/include/wasmtime/store.hhindex 766cd8fdeb..1f386751b7 100644--- a/crates/c-api/include/wasmtime/store.hh+++ b/crates/c-api/include/wasmtime/store.hh@@ -233,7 +233,7 @@ public:/// Runs a garbage collection pass in the referenced store to collect loose/// GC-managed objects, if any are available.- void gc() { context().gc(); }+ Result<std::monostate> gc() { return context().gc(); }private:template <typename F>diff --git a/examples/anyref.cc b/examples/anyref.ccindex 80cf96961a..189dcdd704 100644--- a/examples/anyref.cc+++ b/examples/anyref.cc@@ -95,7 +95,10 @@ int main() {}std::cout << "GCing within the store...\n";- store.context().gc();+ if (!store.context().gc()) {+ std::cerr << "> Error while collecting garbage\n";+ return 1;+ }std::cout << "Done.\n";return 0;diff --git a/examples/externref.cc b/examples/externref.ccindex 4925852001..41207264a0 100644--- a/examples/externref.cc+++ b/examples/externref.cc@@ -50,5 +50,10 @@ int main() {<< "\n";std::cout << "Running a gc..\n";- store.context().gc();+ if (!store.context().gc()) {+ std::cerr << "> Error while collecting garbage\n";+ return 1;+ }++ return 0;}