Impl Clone for EngineId. EngineId distinguishes between clone() calls, so it returns a new ID when cloned.

This commit is contained in:
Nick Lewycky
2020-06-08 15:11:16 -07:00
parent 4e5f878560
commit ebceefe36c
4 changed files with 9 additions and 31 deletions

View File

@@ -16,22 +16,13 @@ use wasmer_runtime::{
};
/// A WebAssembly `JIT` Engine.
#[derive(Clone)]
pub struct JITEngine {
inner: Arc<Mutex<JITEngineInner>>,
tunables: Arc<dyn Tunables + Send + Sync>,
engine_id: EngineId,
}
impl Clone for JITEngine {
fn clone(&self) -> Self {
Self {
inner: self.inner.clone(),
tunables: self.tunables.clone(),
engine_id: EngineId::default(),
}
}
}
impl JITEngine {
/// Create a new `JITEngine` with the given config
#[cfg(feature = "compiler")]

View File

@@ -13,22 +13,13 @@ use wasmer_engine::{Artifact, DeserializeError, Engine, EngineId, Tunables};
use wasmer_runtime::{SignatureRegistry, VMSharedSignatureIndex, VMTrampoline};
/// A WebAssembly `Native` Engine.
#[derive(Clone)]
pub struct NativeEngine {
inner: Arc<Mutex<NativeEngineInner>>,
tunables: Arc<dyn Tunables + Send + Sync>,
engine_id: EngineId,
}
impl Clone for NativeEngine {
fn clone(&self) -> Self {
Self {
inner: self.inner.clone(),
tunables: self.tunables.clone(),
engine_id: EngineId::default(),
}
}
}
impl NativeEngine {
/// Create a new `NativeEngine` with the given config
#[cfg(feature = "compiler")]

View File

@@ -67,6 +67,12 @@ impl EngineId {
}
}
impl Clone for EngineId {
fn clone(&self) -> Self {
Self::default()
}
}
impl Default for EngineId {
fn default() -> Self {
static NEXT_ID: AtomicUsize = AtomicUsize::new(0);

View File

@@ -18,6 +18,7 @@ extern "C" fn dummy_trampoline(
}
/// A WebAssembly `Dummy` Engine.
#[derive(Clone)]
pub struct DummyEngine {
signatures: Arc<SignatureRegistry>,
features: Arc<Features>,
@@ -25,17 +26,6 @@ pub struct DummyEngine {
engine_id: EngineId,
}
impl Clone for DummyEngine {
fn clone(&self) -> Self {
Self {
signatures: self.signatures.clone(),
features: self.features.clone(),
tunables: self.tunables.clone(),
engine_id: EngineId::default(),
}
}
}
impl DummyEngine {
#[cfg(feature = "compiler")]
pub fn new(tunables: impl Tunables + 'static + Send + Sync) -> Self {