Skip to content

Commit 8f8ce2e

Browse files
abrownalexcrichton
andcommitted
review: wrap Linker with an Arc for faster cloning
Co-authored-by: Alex Crichton <[email protected]>
1 parent d22aff8 commit 8f8ce2e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/wasi-threads/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use anyhow::{anyhow, Result};
66
use rand::Rng;
7-
use std::thread;
7+
use std::sync::Arc;
88
use wasmtime::{Caller, Linker, Module, SharedMemory, Store};
99
use wasmtime_wasi::maybe_exit_on_error;
1010

@@ -14,11 +14,11 @@ const WASI_ENTRY_POINT: &str = "wasi_thread_start";
1414

1515
pub struct WasiThreadsCtx<T> {
1616
module: Module,
17-
linker: Linker<T>,
17+
linker: Arc<Linker<T>>,
1818
}
1919

2020
impl<T: Clone + Send + 'static> WasiThreadsCtx<T> {
21-
pub fn new(module: Module, linker: Linker<T>) -> Self {
21+
pub fn new(module: Module, linker: Arc<Linker<T>>) -> Self {
2222
Self { module, linker }
2323
}
2424

src/commands/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ fn populate_with_wasi(
504504
})?;
505505
host.wasi_threads = Some(std::sync::Arc::new(WasiThreadsCtx::new(
506506
_module,
507-
linker.clone(),
507+
std::sync::Arc::new(linker.clone()),
508508
)));
509509
}
510510
}

0 commit comments

Comments
 (0)