Skip to content

Commit 890c825

Browse files
committed
review: conditionally use std::sync::Arc
1 parent b366b72 commit 890c825

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/commands/run.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ use wasmtime_cli_flags::{CommonOptions, WasiModules};
1212
use wasmtime_wasi::maybe_exit_on_error;
1313
use wasmtime_wasi::sync::{ambient_authority, Dir, TcpListener, WasiCtxBuilder};
1414

15+
#[cfg(any(feature = "wasi-crypto", feature = "wasi-nn", feature = "wasi-threads"))]
16+
use std::sync::Arc;
17+
1518
#[cfg(feature = "wasi-nn")]
1619
use wasmtime_wasi_nn::WasiNnCtx;
1720

@@ -417,11 +420,11 @@ impl RunCommand {
417420
struct Host {
418421
wasi: Option<wasmtime_wasi::WasiCtx>,
419422
#[cfg(feature = "wasi-crypto")]
420-
wasi_crypto: Option<std::sync::Arc<WasiCryptoCtx>>,
423+
wasi_crypto: Option<Arc<WasiCryptoCtx>>,
421424
#[cfg(feature = "wasi-nn")]
422-
wasi_nn: Option<std::sync::Arc<WasiNnCtx>>,
425+
wasi_nn: Option<Arc<WasiNnCtx>>,
423426
#[cfg(feature = "wasi-threads")]
424-
wasi_threads: Option<std::sync::Arc<WasiThreadsCtx<Host>>>,
427+
wasi_threads: Option<Arc<WasiThreadsCtx<Host>>>,
425428
}
426429

427430
/// Populates the given `Linker` with WASI APIs.
@@ -470,10 +473,10 @@ fn populate_with_wasi(
470473
#[cfg(feature = "wasi-crypto")]
471474
{
472475
wasmtime_wasi_crypto::add_to_linker(linker, |host| {
473-
std::sync::Arc::get_mut(host.wasi_crypto.as_mut().unwrap())
476+
Arc::get_mut(host.wasi_crypto.as_mut().unwrap())
474477
.expect("wasi-crypto is not implemented with multi-threading support")
475478
})?;
476-
host.wasi_crypto = Some(std::sync::Arc::new(WasiCryptoCtx::new()));
479+
host.wasi_crypto = Some(Arc::new(WasiCryptoCtx::new()));
477480
}
478481
}
479482

@@ -485,10 +488,10 @@ fn populate_with_wasi(
485488
#[cfg(feature = "wasi-nn")]
486489
{
487490
wasmtime_wasi_nn::add_to_linker(linker, |host| {
488-
std::sync::Arc::get_mut(host.wasi_nn.as_mut().unwrap())
491+
Arc::get_mut(host.wasi_nn.as_mut().unwrap())
489492
.expect("wasi-nn is not implemented with multi-threading support")
490493
})?;
491-
host.wasi_nn = Some(std::sync::Arc::new(WasiNnCtx::new()?));
494+
host.wasi_nn = Some(Arc::new(WasiNnCtx::new()?));
492495
}
493496
}
494497

@@ -502,9 +505,9 @@ fn populate_with_wasi(
502505
wasmtime_wasi_threads::add_to_linker(linker, &_module, |host| {
503506
host.wasi_threads.as_ref().unwrap()
504507
})?;
505-
host.wasi_threads = Some(std::sync::Arc::new(WasiThreadsCtx::new(
508+
host.wasi_threads = Some(Arc::new(WasiThreadsCtx::new(
506509
_module,
507-
std::sync::Arc::new(linker.clone()),
510+
Arc::new(linker.clone()),
508511
)?));
509512
}
510513
}

0 commit comments

Comments
 (0)