mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-13 05:48:45 +00:00
Move StoreId to common wasmer_types
This commit is contained in:
@@ -234,30 +234,8 @@ mod objects {
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
use crate::js::{function_env::VMFunctionEnvironment, vm::VMGlobal};
|
||||
use std::{
|
||||
fmt,
|
||||
marker::PhantomData,
|
||||
num::{NonZeroU64, NonZeroUsize},
|
||||
sync::atomic::{AtomicU64, Ordering},
|
||||
};
|
||||
|
||||
/// Unique ID to identify a context.
|
||||
///
|
||||
/// Every handle to an object managed by a context also contains the ID of the
|
||||
/// context. This is used to check that a handle is always used with the
|
||||
/// correct context.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
pub struct StoreId(NonZeroU64);
|
||||
|
||||
impl Default for StoreId {
|
||||
// Allocates a unique ID for a new context.
|
||||
fn default() -> Self {
|
||||
// No overflow checking is needed here: overflowing this would take
|
||||
// thousands of years.
|
||||
static NEXT_ID: AtomicU64 = AtomicU64::new(1);
|
||||
Self(NonZeroU64::new(NEXT_ID.fetch_add(1, Ordering::Relaxed)).unwrap())
|
||||
}
|
||||
}
|
||||
use std::{fmt, marker::PhantomData, num::NonZeroUsize};
|
||||
pub use wasmer_types::StoreId;
|
||||
|
||||
/// Trait to represent an object managed by a context. This is implemented on
|
||||
/// the VM types managed by the context.
|
||||
|
||||
@@ -3,9 +3,10 @@ use crate::sys::engine::{default_engine, Engine};
|
||||
use derivative::Derivative;
|
||||
use std::fmt;
|
||||
use wasmer_compiler::Tunables;
|
||||
use wasmer_types::OnCalledAction;
|
||||
use wasmer_vm::{init_traps, StoreId, TrapHandlerFn};
|
||||
use wasmer_types::{OnCalledAction, StoreId};
|
||||
use wasmer_vm::{init_traps, TrapHandlerFn};
|
||||
|
||||
#[cfg(feature = "sys")]
|
||||
use wasmer_vm::StoreObjects;
|
||||
|
||||
/// Call handler for a store.
|
||||
|
||||
Reference in New Issue
Block a user