|
2 | 2 | //! |
3 | 3 | //! [`wasi-threads`]: https://github.com/WebAssembly/wasi-threads |
4 | 4 |
|
5 | | -use anyhow::{Result, anyhow}; |
6 | 5 | use std::panic::{AssertUnwindSafe, catch_unwind}; |
7 | 6 | use std::sync::Arc; |
8 | 7 | use std::sync::atomic::{AtomicI32, Ordering}; |
9 | 8 | use std::thread; |
10 | | -use wasmtime::{Caller, ExternType, InstancePre, Linker, Module, SharedMemory, Store}; |
| 9 | +use wasmtime::{ |
| 10 | + Caller, ExternType, InstancePre, Linker, Module, Result, SharedMemory, Store, format_err, |
| 11 | +}; |
11 | 12 |
|
12 | 13 | // This name is a function export designated by the wasi-threads specification: |
13 | 14 | // https://github.com/WebAssembly/wasi-threads/#detailed-design-discussion |
@@ -141,7 +142,7 @@ pub fn add_to_linker<T: Clone + Send + 'static>( |
141 | 142 | store: &wasmtime::Store<T>, |
142 | 143 | module: &Module, |
143 | 144 | get_cx: impl Fn(&mut T) -> &WasiThreadsCtx<T> + Send + Sync + Copy + 'static, |
144 | | -) -> anyhow::Result<()> { |
| 145 | +) -> wasmtime::Result<()> { |
145 | 146 | linker.func_wrap( |
146 | 147 | "wasi", |
147 | 148 | "thread-spawn", |
@@ -170,7 +171,7 @@ pub fn add_to_linker<T: Clone + Send + 'static>( |
170 | 171 | let mem = SharedMemory::new(module.engine(), m.clone())?; |
171 | 172 | linker.define(store, import.module(), import.name(), mem.clone())?; |
172 | 173 | } else { |
173 | | - return Err(anyhow!( |
| 174 | + return Err(format_err!( |
174 | 175 | "memory was not shared; a `wasi-threads` must import \ |
175 | 176 | a shared memory as \"memory\"" |
176 | 177 | )); |
|
0 commit comments