Skip to content

Commit 2d7107c

Browse files
committed
review: conditionally use std::sync::Arc
1 parent e0daef9 commit 2d7107c

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

@@ -416,11 +419,11 @@ impl RunCommand {
416419
struct Host {
417420
wasi: Option<wasmtime_wasi::WasiCtx>,
418421
#[cfg(feature = "wasi-crypto")]
419-
wasi_crypto: Option<std::sync::Arc<WasiCryptoCtx>>,
422+
wasi_crypto: Option<Arc<WasiCryptoCtx>>,
420423
#[cfg(feature = "wasi-nn")]
421-
wasi_nn: Option<std::sync::Arc<WasiNnCtx>>,
424+
wasi_nn: Option<Arc<WasiNnCtx>>,
422425
#[cfg(feature = "wasi-threads")]
423-
wasi_threads: Option<std::sync::Arc<WasiThreadsCtx<Host>>>,
426+
wasi_threads: Option<Arc<WasiThreadsCtx<Host>>>,
424427
}
425428

426429
/// Populates the given `Linker` with WASI APIs.
@@ -469,10 +472,10 @@ fn populate_with_wasi(
469472
#[cfg(feature = "wasi-crypto")]
470473
{
471474
wasmtime_wasi_crypto::add_to_linker(linker, |host| {
472-
std::sync::Arc::get_mut(host.wasi_crypto.as_mut().unwrap())
475+
Arc::get_mut(host.wasi_crypto.as_mut().unwrap())
473476
.expect("wasi-crypto is not implemented with multi-threading support")
474477
})?;
475-
store.data_mut().wasi_crypto = Some(std::sync::Arc::new(WasiCryptoCtx::new()));
478+
store.data_mut().wasi_crypto = Some(Arc::new(WasiCryptoCtx::new()));
476479
}
477480
}
478481

@@ -484,10 +487,10 @@ fn populate_with_wasi(
484487
#[cfg(feature = "wasi-nn")]
485488
{
486489
wasmtime_wasi_nn::add_to_linker(linker, |host| {
487-
std::sync::Arc::get_mut(host.wasi_nn.as_mut().unwrap())
490+
Arc::get_mut(host.wasi_nn.as_mut().unwrap())
488491
.expect("wasi-nn is not implemented with multi-threading support")
489492
})?;
490-
store.data_mut().wasi_nn = Some(std::sync::Arc::new(WasiNnCtx::new()?));
493+
store.data_mut().wasi_nn = Some(Arc::new(WasiNnCtx::new()?));
491494
}
492495
}
493496

@@ -501,9 +504,9 @@ fn populate_with_wasi(
501504
wasmtime_wasi_threads::add_to_linker(linker, store, &_module, |host| {
502505
host.wasi_threads.as_ref().unwrap()
503506
})?;
504-
store.data_mut().wasi_threads = Some(std::sync::Arc::new(WasiThreadsCtx::new(
507+
store.data_mut().wasi_threads = Some(Arc::new(WasiThreadsCtx::new(
505508
_module,
506-
std::sync::Arc::new(linker.clone()),
509+
Arc::new(linker.clone()),
507510
)?));
508511
}
509512
}

0 commit comments

Comments
 (0)